0

I'm new to Wget. Following online examples, I am trying to log in to a simple page using the following command:

wget --post-data='entry=85482564&submit3=LOGIN' \ --save-cookies=my-cookies.txt --keep-session-cookies \ https://www.abczyx.com

I get the following error:

SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
'submit3' is not recognized as an internal or external command, operable program or batch file.

I'm guessing that it doesn't quite recognize the &, but I am not sure how to fix it. I'm running Windows 7 cmd line. A side question, why use "\"? I see some examples with it, and some without it. I get issues with it.

6
  • 1
    Those "\" have to be removed. They only serve to show linebreaks inside print output that must not be used when actually running commands. Commented Oct 4, 2012 at 20:55
  • Thank you for this. I have removed the slash, yet I still get the same error. If I remove one of the post data like so: --post-data='submit3=LOGIN', it works. Doesn't matter which one I remove...this is a clear indication to me that it is the "&" issue. Commented Oct 4, 2012 at 21:00
  • What "&"? Have a try putting quotes around the url, it might be the shell interpreting the "://": wget --post-data='entry=85482564&submit3=LOGIN' --save-cookies=my-cookies.txt --keep-session-cookies "https://www.abczyx.com" Commented Oct 4, 2012 at 21:02
  • I meant the "&" between the post parameters "entry" and submit3. If I remove one of it, it works. Tried single and double quotes around url...doesn't work. Commented Oct 4, 2012 at 21:08
  • That is funny. I see no reason why a shell should escape that. However I realize you are using MS Windows for this, quite a few things work in a strange und enexplicable way under those systems... Ok, if it's the "&" then try to escape it: use "\&" instead. Commented Oct 5, 2012 at 6:15

5 Answers 5

3

After doing some reading, I found that because it is MS DOS, they do not interpret the special characters correctly. Adding quotes around it ("&") did the trick.

Sign up to request clarification or add additional context in comments.

Comments

1

In Windows the escape sign is the caret, ^, not backslash, \. So in the batch file it should look like 'entry=85482564^&submit3=LOGIN'.

Comments

0

For me what worked was change & to %26 as in --post-data 'login=foo%26pass=bar'

also if you are posting an email addrress be sure to change the @ to %40

Other codes: https://en.wikipedia.org/wiki/Percent-encoding

Comments

0

Yes, there is a mistake(I'd say a very serious mistake) in wget's manual. In the manual it says:

Log in to the server.

This can be done only once. wget --save-cookies cookies.txt
--post-data 'user=foo&password=bar'
http://example.com/auth.php

So you do something like

wget --save-cookies cookies.txt \
--post-data 'user=yourUser12%23125&password=yourPassword12%241' \
http://www.websitelink.com/

Which ovbiously doesn't work for multiple reasons. First, you have to remove the \ symbols because they get in the way, second, you have to remove line breaks themselves because when you paste it in your command line tool, it will execute them just as if you pressed enter after each of the lines, which will result in trying to execute that command as 3 separate commands:

First:

wget --save-cookies cookies.txt \

Second:

--post-data 'user=yourUser12%23125&password=yourPassword12%241' \

Third:

http://www.websitelink.com/

Ok, so you remove the slashes and then realize that you have to also remove line breaks by yourself, but it still doesn't work. At this point it's pepehands in the air. So what do you do now? Somehow you have to automagically realize that the & symbol should be also percent-encoded. So you turn

Log in to the server.

This can be done only once. wget --save-cookies cookies.txt
--post-data 'user=foo&password=bar'
http://example.com/auth.php

To this:

wget --save-cookies cookies.txt --post-data 'user=yourUser12%23125%26password=yourPassword12%241' http://www.websitelink.com/

And it starts working!

Comments

0

with capital, V works for me. wget -V

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.