#!/usr/bin/perl -w use WWW::Mechanize qw(!head); use HTTP::Cookies; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); print header; print start_html("email"); $user=param("user"); $pass=param("password"); ###go to login page and login. #$url = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fnsr%3D1%26ui%3Dhtml%26zy%3Dl&bsv=1k96igf4806cy<mpl=default<mplcache=2"; $url="https://www.google.com/accounts/ServiceLoginAuth?service=mail"; $mech = WWW::Mechanize->new() or die "cannot create a new agent"; $mech->cookie_jar(HTTP::Cookies->new()); $mech->get($url) or die 'cannot get'; print $mech->content(); $mech->form_number(1); die "not logging in",$mech->response->status_line unless $mech->success; $mech->field(Email => 'xxxxxxx'); $mech->field(Passwd => 'yyyyyy'); $mech->submit(); #Go to the next link, now that we are logged in. $url = 'http://mail.google.com/mail/contacts/data/export?exportType=ALL&groupToExport=&out=Google_CSV'; $mech->get($url)||die "din get"; print $mech->content();