Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I need help with WWW::Mechanize to automate a login to a page that uses Duo-Authentication. I am able to load the credentials and login but I need to silently pass the second check using the information that is saved in the cookies by the browser (Chrome or any other browser if necessary). Once this is achieved I should be able to things I was able to do before the implementation of the Duo-Authentication.

This call
returns this warning: "Decrypted cookies is not set up at..."
Here is what I have so far.
#!/usr/bin/perl -w use strict; use Data::Dumper; use WWW::Mechanize; use HTTP::Cookies::Chrome; my $username = '**********'; my $passwd = '*********'; my $cookie_file = 'C:/Users/username/AppData/Local/Google/Chrome/User +Data/Default/Cookies'; #chrome cookies path on windows my $cookie_jar = HTTP::Cookies::Chrome->new( # chrome_safe_storage_password => '***", # I don't know what t +o do here file => $cookie_file, # autosave => 1, # ignore_discard => 0, ); $cookie_jar->load($cookie_file); my $mech = WWW::Mechanize->new( cookie_jar => $cookie_jar, ); #$mech->cookie_jar->scan(sub { print Dumper \@_ }); #print $cookie_jar->as_string; my $uri = URI->new( "https://www.*****.com" ); $mech->get( $uri ); unless ($mech->success) { my $mesg = $mech->response->status_line; print $mesg; goto END; } $mech->set_fields( username => $username, password => $passwd, ); $mech -> submit(); sleep(2); $mech->success() or die "Can't fetch the Requested page"; my @form = ( "formname" ); $mech->form_with_fields( @form ); my $value ='******'; eval {$mech->select('fieldName', $value)}; if ($@ and $@ =~ /Illegal value/) { print "This page has not been loaded..."; goto END; } END :

In reply to Loading browser cookies into WWW::Mechanize by bakiperl

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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-06-07 01:53 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.