Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to download the webpage, but it requires a username and password. So I have used this:

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

But it does not work! Why?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

That's possibly because the server uses session cookies to track authentication. Add the option --save-cookies alongside to force the cookie to be saved. So your commmand looks like this:

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

I haven't tested it though.

share|improve this answer

Here is an example script which will dump cookies from Chrome (v19).

#!/bin/bash -e
# Quick and dirty script which dumps all Chrome cookies in 
# the specified SQLite database to stdout in Netscape format.


echo -e '.mode tabs \n select host_key, httponly, path, secure, ' \
  'expires_utc/10000000, name, value from cookies;' |
  sqlite3 $COOKIE_FILE |
  sed -e 's/\t0\t/\tFALSE\t/g ' -e 's/\t1\t/\tTRUE\t/g'
share|improve this answer
It worked after replacing the ~ in COOKIE_FILE by its particular value in my configuration. I suppose there's a lacking export or the like in my system. The error that I received before making this change was unable to open database file. – naitoon Aug 11 '13 at 0:59
Please "quote" the variable in sqlite $COOKIE_FILE. – ankostis Jun 16 at 16:18

As Colin suggests, this site is using session cookies for authentication, but his answer won't fully work because it won't get you logged in.

You need to have a cookie for wget to pass to the server on the initial request. Use wget's --load-cookies option (documented here). Note that this uses the old cookies.txt file format rather than the sqlite database format that Firefox and Chrome currently use.

Here's what I would do:

  1. Using Firefox or Chrome, go to the site and log in. (Make sure your browser is set to save cookies)
  2. Quit your browser
  3. Find your cookie file
  4. Convert to cookies.txt format (see notes below on this)
  5. wget --load-cookies cookies.txt

Options to convert from sqlite format to cookies.txt include a python script or a simpler sqlite script (in the comments on that previous link), but the easiest for you might be to install this Firefox extension.

share|improve this answer

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.