dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:

I searched the site about it, but couldn't find any nodes--though I admit I didn't try very long; for some reason the past several weeks the site's been going *real* slow.

I want to write a perl program that'll login to my Yahoo account, retrieve the text from the e-mails within a certain category, change the text to html, then ftp the html to my web-site. The last two I don't need help on--in fact, I just finished the html converter. For those that are interested, it takes in a quote of the day, reads in the text, and saves it in appropriate html as the date, i.e., June_29_2001.html.

The problem is, however, that I don't know how to get into my yahoo account and get the mail. I don't have much experiene with working with mailing scripts(well, none to be brutally honest), and I'd like to do it with as few modules as possible. (if it helps, the files are in a directory called 'qotd')

Replies are listed 'Best First'.
Re: Mail and Yahoo and Perl
by tadman (Prior) on Jun 30, 2001 at 00:17 UTC
    It's probably, as bikeNomad says, some form submissions and some HTML scraping. You might need to use cookies, too, which is something LWP::UserAgent supports if you tell it to:
    my $ua = new LWP::UserAgent; $ua->cookie_jar(new HTTP::Cookies);
    Once your program has "logged in" to Yahoo mail, you will get a cookie, not unlike PerlMonks. You can use this to access subsequent pages over a period of time. Although the Yahoo cookie seems to linger around for quite some time, they will ask for your password on a regular basis just to keep you honest, so always be on the lookout for that kind of stuff.

    When it comes to parsing the page itself, you could either go with HTML::Parser, which is a fine tool indeed, but when it comes to cracking tables, HTML::TableExtract is much more powerful. Oddly enough, HTML::TableExtract was developed, apparently, to get data out of Yahoo's finance site. If you tell it the headers of the columns you want, TableExtract will give you an array back that contains the table data.

    Maybe this should be Mail::Yahoo or something.
Re: Mail and Yahoo and Perl
by bikeNomad (Priest) on Jun 29, 2001 at 23:17 UTC
    I don't see what mailing-specific scripts you'd need here. Yahoo mail doesn't have a publically available POP3 or IMAP server; you have to receive mail by going to their website. Which means scraping HTML from their display of email (and probably means that you don't have to convert the email text to HTML, as it will be presented that way already).

    So it just looks like some form submissions followed by HTML parsing.

    update: Absolutely, if you can use their POP3, then do it!

      Actually Yahoo does support POP3. It is not enabled by default and in order to enable it you have to agree to let Yahoo spam you from time to time but it is there and does work well. On the Yahoo Mail page select "Options" then "POP Access & Forwarding." I would imagine that enabling POP access and using one of the POP3 modules on CPAN would be easier than scraping the HTML pages. And of course your script can selectively delete any email sent to you by Yahoo...