Hello, everyone, I have a simulation of the site of the problem please master pointing!

A lot of Web site simulation login I can use Perl to achieve, but encountered a website more special, it should be more difficult to get.

Login interface is as follow:

https://passport.ganji.com/login.php?next=/

I wrote the code is as follows, the user name password is specially registered for testing, to facilitate everyone to test.

username:Perl_Login_Test password:Km97Jc8YA0hBtDWa username:Perl_Login_Test2 password:Km97Jc8YA0hBtDWb username:Perl_Login_Test3 password:Km97Jc8YA0hBtDWc username:Perl_Login_Test4 password:Km97Jc8YA0hBtDWd username:Perl_Login_Test5 password:Km97Jc8YA0hBtDWe username:Perl_Login_Test6 password:Km97Jc8YA0hBtDWf
I use HttpFox to capture the information is logged in will GET this URL.
https://passport.ganji.com/login.php?callback=jQuery182024004868176778 +26_1465784917412&username=Perl_Login_Test&password=Km9%24Jc8%23A0hb&c +heckCode=&setcookie=0&second=&parentfunc=&redirect_in_iframe=&next=%2 +F&__hash__=g9HXulwHOtjjvcVkbJJ3xO2sNdOiS%2F2orrB9fkSBiYSeqFdzpasFkX%2 +F7R2terabF&_=1465784941421
My own analysis is as follows, may not be correct, please correct me, thank you!

__hash__=This parameter should be got from Https://passport.ganji.com/login.php? Next=/?

&_=This maybe means the current time seconds, 13 digit

&checkCode=This is means picture verification code, if needed.

These numbers1820xxxx may be a random number, I do not know how to get this random number, so I used a fixed number, followed by the 13 digit number should be the time, may be from obtain from Https://passport.ganji.com/login.php? Next=/?

In addition, Headers information I also use HttpFox analysis, only one cookie I did not add parameters, because the cookie can not read, can only be passed by Mojo:: UserAgent.

The most difficult,more than a few images appear after the image verification code, how can get the picture verification code?I then manually view the image verification code, the program waiting for manual input automatically log on? How to solove this problem? thanks a lot !

#!/usr/bin/perl $|=1; use Time::HiRes qw/time/; use Data::Dumper; use Mojo::UserAgent; use Mojo::UserAgent::CookieJar; my $ua=Mojo::UserAgent->new; $ua=$ua->inactivity_timeout(10); $ua = $ua->max_redirects(10); my $jar=Mojo::UserAgent::CookieJar->new; $ua = $ua->cookie_jar($jar); my $time1; my $hash; my $login=$ua->get('https://passport.ganji.com/login.php?next=/'=>{ 'Host'=>'passport.ganji.com', 'User-Agent'=>'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/2010 +0101 Firefox/45.0', 'Accept'=>'text/html,application/xhtml+xml,application/xml;q=0.9,* +/*;q=0.8', 'Accept-Language'=>'en-US,en;q=0.5', 'Accept-Encoding'=>'gzip, deflate;', 'Connection'=>'keep-alive', }); if(my $res0=$login->success){ my $body0=$res0->body; if($body0=~m/"display: none">(\d{13})\<\/div\>/){ $time1=$1; } if($body0=~m/\_\_hash\_\_ \= '(.*?)\'\;/){ $hash=$1; } } my $time2=time; $time2=~s/\.//; $time2=~m/^(\d{13})/; $time2=$1; my $url='https://passport.ganji.com/login.php?callback=jQuery182078315 +63733301097_'.$time1.'&username=Perl_Login_Test&password=Km97Jc8YA0hB +tDWa&checkCode=&setcookie=0&second=&parentfunc=&redirect_in_iframe=&n +ext=%2F&__hash__='.$hash.'&_='.$time2; my $tx=$ua->post($url=>{ 'Host'=>'passport.ganji.com', 'User-Agent'=>'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/2010 +0101 Firefox/45.0', 'Accept'=>'text/javascript, application/javascript, application/ec +mascript, application/x-ecmascript, */*; q=0.01', 'Accept-Language'=>'en-US,en;q=0.5', 'Accept-Encoding'=>'gzip, deflate;', 'X-Requested-With'=>'XMLHttpRequest', 'Referer'=>'https://passport.ganji.com/login.php?next=/', 'Connection'=>'keep-alive', }); if(my $res=$tx->success){ print Dumper ($res); my $gh=$ua->get('http://www.ganji.com/user/login_success.php?usern +ame=Perl_Login_Test&next=%2F&second='); if(my $res2=$gh->success){ my $body2=$res2->body; print "$body2\n"; } } else{ print "ERROR!!!\n"; }

In reply to Consult a difficulty of the analog login site. by Perl_Love

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.