Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some parts of wikipedia appear differently when you're logged in. I would like to wget user pages so they would appear as if I was logged in.

Is there a way I can wget user pages like this

this is the login page:
share|improve this question
See also this article: [How to download this webpage with wget?][1] [1]:… – kenorb Feb 20 '13 at 18:34
up vote 30 down vote accepted

The easy way: login with your browser,and give the cookies to wget

Easiest method: in general, you need to provide wget or curl with the (logged-in) cookies from a particular website for them to fetch pages as if you were logged in.

If you are using Firefox, it's easy to do via the Export Cookies add-on. Install the add-on, and:

  1. Go to Tools...Export Cookies, and save the cookies.txt file (you can change the filename/destination).
  2. Open up a terminal, and use wget with the --load-cookies=FILENAME option, e.g.

    wget --load-cookies=cookies.txt
    • For curl, it's curl --cookie cookies.txt ...

(I will try to update this answer for Chrome/Chromium users)

The hard way: use curl (preferably) or wget to manage the entire session

  • A detailed how-to is beyond the scope of this answer, but you use curl with the --cookie-jar or wget with the --save-cookies --keep-session-cookiesoptions, along with the HTTP/S PUT method to log in to a site, save the login cookies, and then use them to simulate a browser.
  • Needless to say, this requires going through the HTML source for the login page (get input field names, etc.), and is often difficult to get to work for sites using anything beyond simple login/password authentication.
  • Tip: if you go this route, it is often much simpler to deal with the mobile version of a website (if available), at least for the authentication step.
share|improve this answer
Nice tip. The code for the mobile site is often way cleaner. – CousinCocaine Jun 4 at 8:39
how does such a cookies.txt look like? – Frederick Nord Jun 17 at 15:38

With cURL is really easy to handle cookies in both ways.

curl -c cookie.txt then will save a file named cookie.txt. But you need to log in, so need to use --data with arguments like: curl -X --data "var1=1&var2=2" -c cookie.txt. Once you get loggued cookie you can send it with: curl -b cookie.txt

Just use -c (--cookie) or -b (--cookie-jar) to save and send.

Note1: Using cURL CLI is a lot of easier than PHP and maybe faster ;)

For save the final content you can easily add > filename.html to your cURL command then save full html code.

Note2 about "full": Yo cannot render javascript with cURL, just get the source code.

share|improve this answer
-X parameter stands for "do post", but using --data=xxx -X is implicit, so you can remove it surely. – erm3nda May 18 '14 at 19:17

Try something like:

wget --keep-session-cookies --save-cookies cookies.txt --post-data 'user=goyamy&passwrd=mypassword'

See also this link:

How to download this webpage with wget?

share|improve this answer
Just like any output. Use > filename.html to save the output at current dir or put a complete filepath. This applies both Linux and Windows systems. – erm3nda May 18 '14 at 19:14
So, im seeing that wget has many features like cURL, or viceversa. It can do POST, so it can do login to websites. Interesting. – erm3nda May 18 '14 at 19:16

For more complicated website based logins you should also consider to use a Python script and some module which imitates a browser, like instead of curl or wget.

This way session cookies are handled automatically, you can follow links and fill login forms, and so "script" yourself through the login process as if using your web browser.

share|improve this answer
Yeah, using mechanize can be really nice. Also (and originally) available in Perl, if that is more your cup of tea. – andol Apr 3 '13 at 8:52

Have you tried this?

wget --user=username --password=password
share|improve this answer
yes - unfortunately that didn't work =( – user784637 Jul 9 '12 at 23:53
Note: this syntax works for basic HTTP authentication only (where your browser pops up a special Username/Password dialog box), not for webpage-based authentication. – izx Jul 10 '12 at 3:30
basic HTTP authentication url format is but as @izx has say, basic HTTP is browser feature, not PHP programming nor code. If someday you need to access an htaccess protected url you can use that mode ;D – erm3nda May 18 '14 at 19:12
I didn't downvote, but this is not a good way to authenticate: if you, by accident make such scripts public, people can use your password. – Willem Van Onsem Nov 23 '14 at 14:51
What's with the downvotes? May not be a catch all answer but still an answer. – Overcode Aug 6 '15 at 17:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.