udie has asked for the wisdom of the Perl Monks concerning the following question:
hi
i am writting a perl code to import contacts from my gmail account. i have used mechanize, the code works fine when run from the ternminal, but when put on a web server and run using a browser i am getting an error which says bad host name,.....the apache log files show that the mechnize agaent($mech) is not able to find the form, but as i said it works perfectly on terminal...i am really stupped could anyone help me....
the code is
#!/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&pas +sive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3 +Fnsr%3D1%26ui%3Dhtml%26zy%3Dl&bsv=1k96igf4806cy<mpl=default<mplca +che=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->succes +s; $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=AL +L&groupToExport=&out=Google_CSV'; $mech->get($url)||die "din get"; print $mech->content();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: importing contacts using mechanize
by Erez (Priest) on Jun 11, 2008 at 06:37 UTC | |
Re: importing contacts using mechanize
by Anonymous Monk on Jun 11, 2008 at 06:32 UTC | |
by udie (Initiate) on Jun 11, 2008 at 08:32 UTC | |
by Corion (Patriarch) on Jun 11, 2008 at 08:34 UTC | |
by udie (Initiate) on Jun 11, 2008 at 09:04 UTC | |
by udie (Initiate) on Jun 11, 2008 at 09:29 UTC | |
Re: importing contacts using mechanize
by Anonymous Monk on Jun 11, 2008 at 06:35 UTC | |
by udie (Initiate) on Jun 11, 2008 at 08:38 UTC | |
Re: importing contacts using mechanize
by denishowe (Acolyte) on Jan 21, 2010 at 00:03 UTC |
Back to
Seekers of Perl Wisdom