0
我必須填寫多個網頁上的表單。我試圖獲取數據,將html解析爲文本,並將其存儲在單個文件中。每個Web表單都有不同的字段需要填寫;這是其中之一的代碼。我還有三個。建議表示讚賞 - 謝謝!Perl將多個網頁並行機械化
use strict;
use warnings;
my $timeout=40;
use WWW::Mechanize;
use HTML::TreeBuilder;
use HTML::FormatText;
use HTML::Parser;
use autodie qw/ open close /;
use 5.012;
use Win32::IE::Mechanize;
use Time::HiRes 'sleep';
my $m = WWW::Mechanize->new(autocheck => 1);
my $browser = Win32::IE::Mechanize->new(visible => 1);
my $snp = "rs111";
my $content= $browser->get("http://snp-nexus.org/index.html");
my $html = $browser->content;
$browser->form_name ('snpnexus');
$browser->field('batch_text', 'dbsnp rs111');
$browser->tick('ensembl', "ensembl");
$browser->tick('refseq','refseq');
$browser->tick('ucsc','ucsc');
$browser->tick("sift",'sift');
$browser->tick("polyphen",'polyphen');
$browser->tick("chb",'chb');
$browser->tick("chd",'chd');
$browser->tick("tfbs",'tfbs');
$browser->tick("consv",'consv');
$browser->tick("gwas",'gwas');
$browser->tick("indel",'indel');
$browser->tick("mirbase" ,'mirbase');
$browser->tick('gad','gad');
$browser->tick('cnp' , 'cnp');
$browser->click_button('value', 'RUN');
for (0 .. $timeout*20) {
last if $browser->{agent}->ReadyState >=5;
sleep 0.1;
}
my $html2 = $browser->content;
my $Format =HTML::FormatText->new();
my $TreeBuilder =HTML::TreeBuilder->new();
$TreeBuilder->parse($html2);
my $parsed= $Format->format($TreeBuilder);
print $parsed;
是的我可以提交文本文件,但我需要的是使用Perl的機械化,使一個網絡爬蟲,使我可以瀏覽多個頁面以獲得單一的snp id,以實現功能化。所以我只想要如何修改我的代碼,使其一次爲多個網頁工作。謝謝你的時間 – 2013-04-25 08:56:53