免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2827 | 回复: 6

小骆驼第五版下载问题 [复制链接]

论坛徽章:
0
发表于 2008-08-25 19:34 |显示全部楼层
通过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><

论坛徽章:
0
发表于 2008-08-25 19:47 |显示全部楼层
用软件抓下来不成么

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

论坛徽章:
0
发表于 2008-08-25 19:51 |显示全部楼层
这个。。好像不全啊,只是个预览而已

论坛徽章:
0
发表于 2008-08-26 01:10 |显示全部楼层
写的不错了

论坛徽章:
0
发表于 2008-08-26 09:06 |显示全部楼层
原帖由 cobrawgl 于 2008-8-25 19:51 发表
这个。。好像不全啊,只是个预览而已




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


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

论坛徽章:
0
发表于 2008-08-26 09:07 |显示全部楼层
原帖由 cobrawgl 于 2008-8-25 19:47 发表
用软件抓下来不成么

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



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

论坛徽章:
0
发表于 2008-08-26 17:47 |显示全部楼层
好像不全的啊。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP