0

I got some cookies from my browser where I'm well authenticated into a website. I've tried to give them to wget and make it download some internal pages, but all it downloads is authentication page

wget --load-cookies $path/cookies.txt --show-progress --no-check-certificate -p -v -U '$userAgentString'  https://$url

How to get the target page and not authentication page?

aac
  • 55
  • 1
  • 6
  • 1
  • See Why does my shell script choke on whitespace or other special characters? to understand why you need to double-quote your variables. "$path/cookies.txt", "https://$url", and -U "$userAgentString" Directory paths & URLs often contain spaces and other problematic shell metacharacters, so they need to be quoted. 2. Are you sure that "$path/cookies.txt" exists and contains a valid authorisation cookie(s)? what made that file / where did it come from?
  • – cas Jun 01 '22 at 05:39
  • My user agent string was quoted and even not here sometimes, and it's the same. The cookie path is spaceless, the URL neither. The cookie path exists and contain a cookie that I extracted by the same method for another website, successfully downloading its content with it. This file is provided by a cookie extractor plugin from FFA – aac Jun 03 '22 at 09:56
  • You single-quoted $userAgentString. That's a string literal, the shell won't expand it as a variable. You need to use double-quotes, not single-quotes. And, of course, your $path and $url also need to be double-quoted. This isn't an answer to your problem, but a) it's good practice and b) it avoids many potential problems. As for why the download doesn't work, that depends on the web site and what it expects and whether the site owners have made any efforts to block downloading stuff with command line tools (e.g. they may require js for d/l to work). Impossible to answer without site details – cas Jun 03 '22 at 16:11
  • It's not the literal command that I just. The real one contain personal information and no variable. Thanks for the advices! The website is a private one, I can't leak the URL without leaking personal information. What do you need to know? – aac Jun 07 '22 at 07:48