Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: WWW::Mechanize::Chrome Instagram

by nysus (Parson)
on Sep 03, 2019 at 21:31 UTC ( [id://11105532]=note: print w/replies, xml ) Need Help??


in reply to Re^2: WWW::Mechanize::Chrome Instagram
in thread WWW::Mechanize::Chrome Instagram

I don't remember but my code is in the comment there in the previous link. But the original code might have changed. I modified the _mightNavigate sub, line 1585: https://github.com/Corion/WWW-Mechanize-Chrome/blob/d94c8f43a8c72efc994695e7c075dbc849b2c1e4/lib/WWW/Mechanize/Chrome.pm

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^4: WWW::Mechanize::Chrome Instagram
by Corion (Patriarch) on Sep 04, 2019 at 07:11 UTC

    Currently there is no way for the ->click method to avoid waiting on a HTTP response (or to recognize a standard way of no HTTP response). I'm planning to add a parameter that lets you basically send the click event and then continue, so you can manually wait for the event you want. But currently this is not conveniently solvable without resorting to ->eval of Javascript.

      Actually, there already is an (undocumented) option that you can maybe use to avoid the forced waiting for an HTTP response. The option name is intrapage and it skips all that waiting. Actually determining whether all data has arrived is then up to you:

      $mech->click( { intrapage => 1, selector => '#thatButton', single => 1 + } );
Re^4: WWW::Mechanize::Chrome Instagram
by damian1 (Novice) on Sep 06, 2019 at 22:37 UTC
    #!/usr/bin/perl # hash-bang / she-bang / sh-bang use strict; use warnings; use Log::Log4perl ':easy'; use WWW::Mechanize::Chrome; use open ':std', ':encoding(UTF-8)'; sub main () { my $mech; my $res; my $url; my $cookies; my $username; my $password; my $user; my $pass; my @formlist; $user = 'www'; $pass = 'zzzz'; $url = "https://www.instagram.com/accounts/login/?source=auth_swit +cher&hl=en"; $mech = WWW::Mechanize::Chrome->new( launch_exe => 'chromium', launch_arg => ["--no-sandbox", "--disable-setuid-sandbox", + "--remote-debugging-port=9222", "--headless"], ); $mech->allow( javascript => 1 ); $mech->get($url); if ($mech->success()) { $mech->sleep(1); + # waiting for load site $mech->form_number(1); $mech->value( username => $user ); $mech->value( password => $pass ); $mech->eval_in_page(<<'JS'); var cls = document.getElementsByClassName('_0mzm- sqdOP L3NKy + '); Array.prototype.forEach.call(cls, (item) => item.removeAttribu +te('disabled')); JS $mech->click({intrapage => 1, text => 'Log In', single => 1 }) +; $mech->sleep(2); print $mech->content; } else { print "Not connect to: ".$url."\r\n"; } return 0; } main ();

    Now i manually remove disable attribute from button, request send when i click Log in but get me error "The username you entered doesn't belong to an account. Please check your username and try again." when I'm definitely entering the correct data, it looks like he didn't see the login and password completed before sending, this error is probably displayed for an empty login. Anyone have any idea how to log in correctly?

      My guess is that you need to simulate typing to get the form to respond properly.

        Can you show my example? I find function sendkeys() but i don't find example uses for two input, and i don't find enter key code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105532]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-20 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found