http://www.perlmonks.org?node_id=585259


in reply to how to import hotmail addressbook by WWW::Mechanize or something else

The login process looks complicated but it is ultimately cookie based and will just take some working out. You can avoid getting the script to log in by preparing the cookies beforehand.

Try logging into hotmail using Mozilla or Firefox as your browser (I prefer Mozilla for this). Clear the cookies using the cookie manager. Choose the "save my credentials" option when you log in. This saves a number of cookies into the cookies.txt file. (location varies depending on OS but try under C:\Documents and Settings\<MyAccount>\Application Data\Mozilla\Profiles on Windows).

The cookies.txt file is in Netscape Format so you will need to load it up using HTTP::Cookies::Netscape. All your code needs to do now is to handle the redirection (which WWW::Mechanize should do OK).

This is all untested but I have used a similar script elsewhere. In general, Mozilla and LiveHTTPHeaders is a good debug combination.

Replies are listed 'Best First'.
Re^2: how to import hotmail addressbook by WWW::Mechanize or something else
by fayland (Acolyte) on Nov 22, 2006 at 01:49 UTC
    yup, I tried as what you said. no luck indeed.
    use HTTP::Cookies::Netscape; my $cookie_jar = HTTP::Cookies::Netscape->new( file => 'E:/lwp_cookies.dat', autosave => 1, ); my $mech = WWW::Mechanize->new( agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', cookie_jar => $cookie_jar, stack_depth => 1, autocheck => 1, );
    mm, we brought a script written by php. it uses 'curl_exec' and works fine. I tried to search in CPAN. and find WWW::Curl, but failed to install this module. (install progress stoped at test).
    I just wonder whether anyone has written a similar script and give me a hint.
    Thanks for your tip any way, inman.