Perl_Love has asked for the wisdom of the Perl Monks concerning the following question:
but AnyEvent::HTTP is not work, can you help me? thx!my $url='http://www.xmrc.com.cn/net/enterprise/login.aspx'; my $ua=LWP::UserAgent->new(agent=>'Mozilla/5.0 (Windows NT 10.0; rv:46 +.0) Gecko/20100101 Firefox/46.0',timeout=>10); my $cookie_jar=HTTP::Cookies->new(); $ua->cookie_jar($cookie_jar); $ua->request(POST $url, [ '__VIEWSTATE'=>'/wEPDwUKLTQwMDQ2MTU5OGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3 +N0QmFja0tleV9fFgEFF2N0bDAwJEJvZHkkY3RsMDAkZ2V0cHdk', 'ctl00$Body$ctl00$UsernameTextBox'=>'UserName', 'ctl00$Body$ctl00$PasswordTextBox'=>'PassWord', 'ctl00$Body$ctl00$LoginButton'=>'登录' ] ); my $newreq=$ua->request(GET 'http://www.xmrc.com.cn/net/enterprise/Res +ume.aspx?TalentID=95438746')->as_string; print $newreq;
Hello ,afoken , Corion , hippo : AnyEvent::HTTP cannot work ,the reason is that http_post login HTML information only,but could not simulate the login website same as LWP example . I know the pass parameters method of LWP POST ,such as UserName ,PassWord , LoginButton . But I do not know AnyEvent::HTTP is how to transfer the information to the website. I created headers from HttpFox . Could you help to make a simple AnyEvent: : HTTP transfer example for reference ? Even though I am a novice,I like Perl very much ! Thanks a lot ~ hi , ikegami : Thank you for guidance ! you give the example is http_get, I can ues http_get to obtain the Websit. And I think if I want to log on to a website, this situation should be submitted it with http_post. For example of LWPuse Coro; use AnyEvent::HTTP; my $url='http://www.xmrc.com.cn/net/enterprise/login.aspx'; my $cookie_jar={}; my %headers={ 'Host'=>'www.xmrc.com.cn', 'User-Agent'=>'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Ge +cko/20100101 Firefox/44.0', 'Accept'=>'text/html,application/xhtml+xml,application/xml;q=0 +.9,*/*;q=0.8', 'Accept-Language'=>'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3', 'Accept-Encoding'=>'gzip, deflate', 'Referer'=>'http://www.xmrc.com.cn/net/enterprise/login.aspx', 'Content-Type'=>'application/x-www-form-urlencoded', #'keepalive'=>'1', }; http_post( "$url", '__VIEWSTATE'=>'/wEPDwUKLTQwMDQ2MTU5OGQYAQUeX19Db250cm9sc1JlcX +VpcmVQb3N0QmFja0tleV9fFgEFF2N0bDAwJEJvZHkkY3RsMDAkZ2V0cHdk', 'ctl00$Body$ctl00$UsernameTextBox'=>'UserName', 'ctl00$Body$ctl00$PasswordTextBox'=>'PassWord', 'ctl00$Body$ctl00$LoginButton'=>'登录', cookie_jar=>$cookie_jar, headers=>%headers, ,timeout=>10,cb=>Coro::rouse_cb ); my @rouse=Coro::rouse_wait; print $rouse[0];
I do not know how the parameters between the http_post from AnyEvent::HTTP , Kindly ask for help ,thanks a lot ~$ua->request(POST $url, [ '__VIEWSTATE'=>'/wEPDwUKLTQwMDQ2MTU5OGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3 +N0QmFja0tleV9fFgEFF2N0bDAwJEJvZHkkY3RsMDAkZ2V0cHdk', 'ctl00$Body$ctl00$UsernameTextBox'=>'UserName', 'ctl00$Body$ctl00$PasswordTextBox'=>'PassWord', 'ctl00$Body$ctl00$LoginButton'=>'登录' ] );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help, AnyEvent::HTTP no work!
by Corion (Patriarch) on May 09, 2016 at 07:29 UTC | |
by ikegami (Patriarch) on May 09, 2016 at 16:19 UTC | |
|
Re: Help, AnyEvent::HTTP no work!
by afoken (Chancellor) on May 09, 2016 at 06:39 UTC | |
|
Re: Help, AnyEvent::HTTP no work!
by hippo (Archbishop) on May 09, 2016 at 08:27 UTC | |
by Perl_Love (Acolyte) on May 09, 2016 at 12:17 UTC | |
|
Re: Help, AnyEvent::HTTP no work!
by ikegami (Patriarch) on May 09, 2016 at 16:11 UTC |