作者doxing (【肆总部】)
看板Perl
标题[问题] 请问要如何撷取网页中的某个表格後输出到萤幕上
时间Mon Aug 25 21:57:26 2008
我目前有一段code可以对某个网页的搜寻栏给一个input
submit出去之後网页会帮忙计算出好几个表格
我需要撷取其中一个
这个我就不知道该怎麽写
本来想用比对的方法
爬了文也找不到
请问有没有前辈有解决过这类问题的
我去的网页是
http://gibk26.bse.kyutech.ac.jp/jouhou/readout/
在网页中间有一句话
"Start ReadOut Calculations by filling up the following form"
这句话下面有一个空白栏位可以输入四码的input
栏位里会有一个预设sample
按下空白栏位下方的submit後
网页会开始计算一些东西
然後出现一个新页面
我需要中间的某一个表格
就是"PDB file name : xxxx"
这句话下的表格
我目前有的code可以做到将input输入
然後计算後的页面print在linux页面上
code如下
#!/usr/bin/perl
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
$ua->cookie_jar({});
# fill the form action process url in the following string
my $req = HTTP::Request->new(POST => '
http://gibk21.bse.kyutech.ac.jp/cgi-bin/
readout/get-from-pdb.cgi');
$req->content_type('application/x-www-form-urlencoded');
# pdbcode is the field on the web pages with title
"Enter three letter PDB code".
# put the ID you want to calculate after "="
$req->content('pdbcode=1a01');
my $res = $ua->request($req);
# if the request success, it should return the result and print the page it get
on screen with plain html text.
if ($res->is_success;$res =~ /PDB\sfile\sname/) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
请问我应该怎麽写才能撷取我想要的表格
希望有经验的前辈能够帮忙
感谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.193.227.120
1F:推 johnion:网页 检视原始档...你应该就知道怎做了 08/28 19:06
2F:→ johnion:希望对你有帮助 08/28 19:06