Reputation: 21
İ am very new to perl module www::mechanize
and I want to functionalize snp id. For that I have to make a web crawler, but i am having difficulties . İ dont know how to use field names or how to assign values.
I have to access this website: http://www.ncbi.nlm.nih.gov/projects/SNP/ .Please tell what are the fieldnames here. Thanks in advance.
I mean to specify a field name here I have to put the snp id for search.
I am not understanding what to do.
Kindly anybody help.
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();
Upvotes: 1
Views: 1642
Reputation: 10666
Try this version (your form is named Search and field name you need is db
):
$mech->submit_form(
name => "Search",
fields => {
db => $snp,
},
button => "submit",
);
Upvotes: 0
Reputation: 10666
There are developer tools for each web browser: Dragonfly for the Opera (it's built-in and I use it most of the time), Firebug for the Firefox etc. I most of the such tools you need to right click on the element you need to look at and select something like "Inspect element with..."
Upvotes: 0
Reputation: 386706
Use a tool such as the Web Developer add-on for Firefox.
The page has three forms.
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
Upvotes: 5