At 04:27 PM 8/10/2008, you wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rick Nakroshis wrote:
> Micah,
>
> If you will excuse a quick question about Wget, I'm trying to find out
> if I can use it to download a page from Yahoo that requires me to be
> logged in using my Yahoo profile name and password.  It's a display of a
> CSV file, and the only wrinkle is trying to get past the Yahoo login.
>
> Try as I may, I just can't seem to find anything about Wget and Yahoo.
> Any suggestions or pointers?

Hi Rick,

In the future, it's better if you post questions to the mailing list at
wget@sunsite.dk; I don't always have time to respond.

The easiest way to do what you want may be to log in using your browser,
and then tell Wget to use the cookies from your browser, using
- --load-cookies=<path-to-browser's-cookies>. Of course, this only works
if your browser saves its cookies in the standard text format (Firefox
prior to version 3 will do this), or can export to that format (note
that someone contributed a patch to allow Wget to work with Firefox 3
cookies; it's linked from http://wget.addictivecode.org/, it's
unoffocial so I can't vouch for its quality).

Otherwise, you can perform the login using Wget, saving the cookies to a
file of your choice, using --post-data=..., --save-cookies=cookies.txt,
and probably --keep-session-cookies. This will require that you know
what data to place in --post-data, which generally requires that you dig
around in the HTML to find the right form field names, and where to post
them.

For instance, if you find a form like the following within the page
containing the log-in form:

<form action="/doLogin.php" method="POST">
  <input type="text" name="s-login">
  <input type="password" name="s-pass">
</form>

then you need to do something like:

  $ wget --post-data='s-login=USERNAME&s-pass=PASSWORD' \
    --save-cookies=my-cookies.txt --keep-session-cookies \
    http://HOSTNAME/doLogin.php

(Note that you _don't_ necessarily send the information to the page that
 had the login page: you send it to the spot mentioned in the "action"
attribute of the password form.)

Once this is done, you _should_ be able to perform further operations
with Wget as if you're logged in, by using

  $ wget --load-cookies=my-cookies.txt --save-cookies=my-cookies.txt \
    --keep-session-cookies ...

(I'm going to put this up on the Wgiki Faq now, at
http://wget.addictivecode.org/FrequentlyAskedQuestions)

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer.
GNU Maintainer: wget, screen, teseq
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIn09A7M8hyUobTrERAu04AJ9EgRoBBhvNCDwOt87f91p+HpWktACdFgMM
KEfliBtfrPBbh/XdvusEPiw=
=qlGZ
-----END PGP SIGNATURE-----


Micah,

Thank you for taking the time to answer so thoroughly, and doing so promptly, too. You've given me a great boost forward, and I appreciate it.

Thank you, sir!


Rick

Reply via email to