Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I wound up with this code a while ago when I was troubleshooting some issues with cookies, logging into a google adwords account. I did eventually get it to work. YMMV...
my $cookie_jar = HTTP::Cookies->new; $cookie_jar->clear; # shouldn't be necessary since object was newl +y created in above line but this is all experimentation... # A variable that holds our POST request to the site $ENV{HTTPS_VERSION} = 3; my $action = POST 'https://adwords.google.com/select/LoginValidati +on', [ 'hl' => $language, 'login.userid' => $adwordsEmailLogin, 'login.password' => $adwordsPassword, 'login' => 'Login' ]; my $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); # We disguise ourselves as Internet Explorer $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); $ua->timeout(30); #$ENV{HTTPS_PROXY} = 'http://proxy.host:proxy_port'; #if need prox +y if ($proxy) { logMessage( "adwordsLogin: Logging into adwords using proxy $p +roxy.\n"); $ua->proxy('http',$proxy); # should this be https? No, seems +to work as is. # actually, not sure. check this later. } my $www = $ua->request( $action ); # In the event that the request to google fails my $headers = new HTTP::Headers; $headers = $www->headers(); my $redir = $headers->header('Location'); #target url my $action2 = GET 'https://adwords.google.com'.$redir; my $www2 = $ua->request( $action2 ); unless ($www2->is_success) { logMessage( "AdwordsLogin: The error code: " . $www2->code . " + was returned!"); } $cookie_jar->extract_cookies($www2); # Put the HTML into a seperate variable #my $content = $www2->content; # test #open F, "> adwordsLoginResult.html"; print F $content; close F; $adwordsLoginTries++; return \$cookie_jar;

In reply to Re: Passing a cookie with LWP::UserAgent by tphyahoo
in thread Passing a cookie with LWP::UserAgent by nedals

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found