小骆驼第五版下载问题

小骆驼第五版下载问题

通过google发现小骆驼第五版这里有电子版本

http://proquest.safaribooksonline.com/9780596520106/copy

但由于我刚学perl ,第四版还没有看完,于是在这里发了一帖,请论坛里面的大牛出手下载:


http://bbs.chinaunix.net/thread-1247501-1-1.html

虽然有人说下载中,但一直没有回音,于是肯了两天LWP,还有churchmice 曾经的指点写的下载代码,照毛画虎写了一段下载代码,经过反复调试,程序是运行通了,可是书一页也没有下载下来,郁闷啊!
代码如下,请大牛们指点指点,感谢中。。。。



#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->proxy('http', 'http://username:password@IP:8080/');
my $url="http://proquest.safaribooksonline.com/9780596520106?tocview=true";
my $res = $ua->get($url);
my $html = $res->content;

my @html = $html =~ m%<a href\="([^/]+)$" title\="([^"]+)">%g;

#<a href="/9780596520106/copy" title="Copyright">Copyright</a></div>
#<a href="/9780596520106/preface" title="Preface">Preface</a></div>
#<a href="/9780596520106/introduction" title="Chapter 1.?Introduction">
#<a href="/9780596520106/questions_and_answers" title="Section 1.1.?Questions and Answers">
#<a href="/9780596520106/what_does_quotation_mark_perl_quotation" title="Section 1.2.?What Does “Perl” Stand For?">
部分源代码,详见后面部分


my $filespec=$2;

foreach ( @html ) {
                              
$res = $ua->get("http://proquest.safaribooksonline.com/9780596520106/"."$_");

my $message = $res->get($html,
                         ':content_file' => "$filespec",);
die "Error at $url\n ", $message->status_line, "\n Aborting" unless $message->is_success;
print "Whee, it worked!  I got that  document!\n";

                              
}














<a href="/9780596520106/copy" onclick="void(0);" title="Copyright">Copyright</a></td></tr></table></td></tr><tr valign="top"><td></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/preface" onclick="void(0);" title="Preface">Preface</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/introduction?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/introduction" onclick="void(0);" title="Introduction">Introduction</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/scalar_data?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/scalar_data" onclick="void(0);" title="Scalar Data">Scalar Data</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/lists_and_arrays?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/lists_and_arrays" onclick="void(0);" title="Lists and Arrays">Lists and Arrays</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/subroutines?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/subroutines" onclick="void(0);" title="Subroutines">Subroutines</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/input_and_output?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/input_and_output" onclick="void(0);" title="Input and Output">Input and Output</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/hashes?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><td style="padding-left: 0px"><table cellspacing="0" cellpadding="0"><tr valign="top"><td style=""><a href="/9780596520106/hashes" onclick="void(0);" title="Hashes">Hashes</a></td></tr></table></td></tr><tr valign="top"><td class="icon"><a href="/9780596520106/in_the_world_of_regular_expressions?" onclick="void(0);"><img alt="" src="/static/200808-807-proquest/images/arrow_closed.gif" /></a></td><
用软件抓下来不成么

可惜我忘了那个软件的名字了。。。 searching
这个。。好像不全啊,只是个预览而已
写的不错了


QUOTE:
原帖由 cobrawgl 于 2008-8-25 19:51 发表
这个。。好像不全啊,只是个预览而已

如果没有权限只能是预览,如果有权限,就能全看见了,所以我用了有权限的代理,就可以全部下载。。。。。。。。


继续修改脚本,继续测试中,希望牛人能指点一二。。。。。。。。。。。


QUOTE:
原帖由 cobrawgl 于 2008-8-25 19:47 发表
用软件抓下来不成么

可惜我忘了那个软件的名字了。。。 searching

用软件抓下来,就没有多大意思了,学习 perl就是要用啊,来解决实际问题。。。。。。。。。呵呵。。。。
好像不全的啊。