[英]Perl www::mechanize
對Perl模塊www::mechanize
,這是一個非常新的東西,我想對snp id進行功能化。 為此,我必須制造一個網絡爬蟲,但是我遇到了困難。 ©不知道如何使用字段名稱或如何分配值。 我必須訪問該網站: http: //www.ncbi.nlm.nih.gov/projects/SNP/。請在此處告訴您什么是字段名。 提前致謝。 我的意思是在這里指定字段名稱,我必須輸入要搜索的snp id。 我不知道該怎么辦。 請大家幫忙。
use WWW::Mechanize;
use strict;
use warnings;
my $mech = WWW::Mechanize->new;
my $snp = 'rs111';
my $URL = "http://www.ncbi.nlm.nih.gov/projects/SNP/";
$mech->get($URL);
$mech->submit_form(
form_number => '1',
fields => {
'ID' => $snp,
},
);
print $mech->content();
使用諸如Firefox的Web Developer插件之類的工具。
該頁面具有三種形式。
Id Name Method Action ------ ------ ------ -------------------------------------------------- Search Search post http://www.ncbi.nlm.nih.gov/coreutils/dispatch.cgi Elements ======== Id Name Type Value Label Size Maximum Length ------ ------ ------ -------- ----- ---- ------- ------ Search db select 13 term term text for 24 Search submit submit Go Search SITE hidden NcbiHome
Id Name Method Action -- ----- ------ -------------------------------------------------- frmGo get http://www.ncbi.nlm.nih.gov/entrez/query.fcgi Elements ======== Id Name Type Value Label Size Maximum Length -- -------- ------ ------- ----- ---- ------- ------ db hidden Books cmd hidden Search term input 12 Submit submit Go doptcmdl hidden TOCView
Id Name Method Action -- -------- ------ -------------------------------------------------- searchID post getID.cgi Elements ======== Id Name Type Value Label Size Maximum Length ------ ---------- ------ ------------ ----- ---- ------- ------ searchType hidden adhoc_search sub_id sub_id input ID: IDtype Type select dbSNP_rs submit2 submit Search reset reset Reset
試試這個版本(您的表單名為Search,而您需要的字段名稱是db
):
$mech->submit_form(
name => "Search",
fields => {
db => $snp,
},
button => "submit",
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.