0

The aim is to enter different accounts at the same time. With lynx this is possible using files for each account with the -cfg=~/file argument.

wget has a .wgetrc file that can be configured with:

cookies = on
load_cookies = ~/cookies.txt
save_cookies = ~/cookies.txt

But unlike lynx you don't have the option to invoke it with settings for multiple profiles, it simply loads when wget is started with a single cookie for the same server.

I use the script below that should create and maintain cookies without the need to have the .wgetrc file, but for some reason that I don't know is only successful with .wgetrc.

#!/bin/bash
LOGIN='login=Account&pass=12345678'
    wget -qO- --save-cookies cookies.txt \
        --keep-session-cookies \
        --body-data="$LOGIN" \
        --method=POST \
        http://example.net/?sign_in=1
# after login
wget -qO- --load-cookies cookies.txt \
        http://example.net/user

Based on this information I ask; _Is wget capable of logging in from multiple accounts on the same server? If yes, how?

Lynx is perfectly capable of doing this, but I didn't want to have to use it.

enter image description here

  • just to get this correct, "enter different accounts": This is not about UNIX accounts or anything, this is about sending different login information in the body of a POST request over HTTP? – Marcus Müller Apr 23 '22 at 09:11
  • It's about logging into multiple accounts on a site with wget. But without the need to leave an account to enter another. – Ueliton Alves Dos Santos Apr 23 '22 at 11:29

1 Answers1

2

Instead of putting the cookie loading and saving it in the config file .wgetrc, you can specify, for each wget call independently, --load-cookies filename and --save-cookies filename.

That seems to be what you need. Maybe you also want --keep-session-cookies to explicitly ignore when cookies say "delete me when quitting the program".

This information was very quickly looked up in man wget by searching for "cookie", just in case you think I know something like all command line flags of wget by heart :)

Marcus Müller
  • 21,602
  • 2
  • 39
  • 54
  • The arguments; --load-cookies filename --save-cookies filename --keep-session-cookies It's not working for me, so I use .wgetrc wget -V GNU Wget 1.21.3 built on linux-androideabi. -cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls +ntlm +opie -psl +ssl/openssl – Ueliton Alves Dos Santos Apr 23 '22 at 11:39
  • you can't use .wgetrc if you want different settings for different wget runs. Simple as that. Can you specify in *what* way the argument doesn't work? It's literally exactly the same code as if you put it in your .wgetrc. – Marcus Müller Apr 23 '22 at 11:50
  • This is the exact content in .wgetrc: cookies = on load_cookies = ~/cookies.txt save_cookies = ~/cookies.txt If this content is removed, or the .wgetrc file is deleted, login is not performed with the arguments in the command. But I can see that this only happens with this version of wget in the Termux app for android. Already on Arch Linux the arguments are working, as in your answer. – Ueliton Alves Dos Santos Apr 23 '22 at 14:11
  • in your .wgetrc you speciify the full path, ~/cookies.txt. In your `wget --load-cookies`, you specify only a relative path. Are you sure there's a cookies.txt in the working directory where you execute things? – Marcus Müller Apr 23 '22 at 14:28
  • Yes, I use the full path. The failure occurs only in Termux wget(Android) as described in: https://github.com/sharesourcecode/testing/blob/master/loginlogoff.sh#:~:text=%23%20%2F%25%20wget%20%25%5C%20--%20Simultaneous%20multiple,in%20the%20command%2C%20%5C – Ueliton Alves Dos Santos Apr 23 '22 at 15:34
  • but in your `wget --load-cookies=cookies.txt` call you *do not* use a full path, but a relative one – Marcus Müller Apr 23 '22 at 16:21
  • Still not working on android. I've already marked the issue as resolved, as this works on my Linux. Thank you for your help. – Ueliton Alves Dos Santos Apr 23 '22 at 17:12