[問題] 請問要如何擷取網頁中的某個表格後輸出
我目前有一段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
推
08/28 19:06, , 1F
08/28 19:06, 1F
→
08/28 19:06, , 2F
08/28 19:06, 2F
Perl 近期熱門文章
PTT數位生活區 即時熱門文章