- 论坛徽章:
- 0
|
以下代码来自《Perl & LWP》76页,由于该书出版于2002年后,一直没有再版,
代码中要提交的网页http://dogbert.abebooks.com/abe/BookSearch' 已经变为
'’https://www.abebooks.com/servlet/SearchEntry?errorcode=1',而其中Form数据项也变了。
最主要的是原来是用一个多值Button提交数据,现在确实一个无值Submit,
我这方面是菜鸟,就不知如何处理了。
现在的网页源码:
<BUTTON tabindex="25" class="btn btn-abebooks btn-xs-block"
id="search-button" type="submit">Find Book</BUTTON>
所以 原来的 "bu" => "Start Search",必须修改,请教如何修改?
- #!/usr/bin/perl -w
- # seraph.pl - search for Codex Seraphinianus on abebooks
-
- use strict;
- my $out_file = "result_seraph.html"; # where to save it
-
- use LWP;
- my $browser = LWP::UserAgent->new;
- my $response = $browser->post(
- 'https://www.abebooks.com/servlet/SearchEntry?errorcode=1',#原来:http://dogbert.abebooks.com/abe/BookSearch',
- # That's the URL that the real form submits to.
- [
- #"ph" => "2",
- "an" => "",
- "tn" => "Codex Seraphinianus",#标题
- "pn" => "",
- "sn" => "", #书号
- #"gpnm" => "All Book Stores",
- #"cty" => "All Countries",
- "bi" => "Any Binding",#绑定包装
- "prl" => "",#最低价格
- "prh" => "",
- "sortby" => "0",#排序方式
- #"ds" => "100",
- #"bu" => "Find Book", #这个无效了,那么如何修改,才能提交?????
- ]
- );
-
- die "Error: ", $response->status_line, "\n"
- unless $response->is_success;
-
- open(OUT, ">$out_file") || die "Can't write-open $out_file: $!";
- binmode(OUT);
- print OUT $response->content;
- close(OUT);
- print "Bytes saved: ", -s $out_file, " in $out_file\n";
复制代码 |
|