繁体   English   中英

Perl www :: mechanize

[英]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();

使用诸如FirefoxWeb Developer插件之类的工具

该页面具有三种形式。

  1.  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 
  2.  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 
  3.  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 

每个网络浏览器都有开发人员工具:Opera的Dragonfly (它是内置的,并且我大部分时间都在使用),Firefox的Firebug等。在大多数此类工具中,您需要右键单击所需的元素查看并选择类似“使用...检查元素” 在此处输入图片说明

在此处输入图片说明

试试这个版本(您的表单名为Search,而您需要的字段名称是db ):

$mech->submit_form(
    name => "Search",
    fields => {
        db => $snp,
    },
    button => "submit",
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM