- 论坛徽章:
- 0
|
我想在下面这个(http://bigg.ucsd.edu/bigg/main.pl)网站上提交数据(如“ALD6”),然后跳转到另一页面(http://bigg.ucsd.edu/bigg/post.pl),点击链接能到最后的页面,抓取我需要的数据。
我试着写了一段代码,但是POST上数据后,得到的$res是乱码,请问是什么情况?谢谢!- #!/usr/bin/perl
- use HTTP::Request::Common qw(POST);
- use WWW::Mechanize;
- use LWP::UserAgent;
- # Launch the WWW::Mechanize browser
- my $mech=WWW::Mechanize->new(autocheck=>1);
- # Fetch a page
- my $url='http://bigg.ucsd.edu/bigg/main.pl/';
- $mech->get($url);
- # Post paramaters
- my $req = POST($url,
- organism=>'222668',
- is_associated=>'yes',
- is_associated=>'no',
- is_translocation=>'yes',
- is_translocation=>'no',
- exchanges=>'yes',
- exchanges=>'no',
- reversibility=>'Reversible',
- reversibility=>'Irreversible',
- confidence=>'not evaluated',
- confidence=>'modeling evidence',
- confidence=>'biological evidence',
- locus_text=>'ALD6',
- "\.submit"=>'Find Reactions',
- );
-
- my $res=$mech->request($req);
- sleep(10);
- if ($res->is_success) {
- print "Bingo!\n";
- }else{
- print $res->status_line,"\n";
- print $res->message;
- };
- my $b=$res->content();
- open (LOG, ">>1.txt");
- print LOG $b;
-
复制代码 |
|