hi all! LWP is work:
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;
but AnyEvent::HTTP is not work, can you help me? thx!
use 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];
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 LWP
$ua->request(POST $url, [ '__VIEWSTATE'=>'/wEPDwUKLTQwMDQ2MTU5OGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3 +N0QmFja0tleV9fFgEFF2N0bDAwJEJvZHkkY3RsMDAkZ2V0cHdk', 'ctl00$Body$ctl00$UsernameTextBox'=>'UserName', 'ctl00$Body$ctl00$PasswordTextBox'=>'PassWord', 'ctl00$Body$ctl00$LoginButton'=>'登录' ] );
I do not know how the parameters between the http_post from AnyEvent::HTTP , Kindly ask for help ,thanks a lot ~

In reply to Help, AnyEvent::HTTP no work! 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.