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&ltmpl=default&ltmplca +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();

In reply to importing contacts using mechanize by udie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.