本帖最后由 欢乐chylli 于 2011-11-2 15:27 编辑
为了下载论坛上的dk的那个资源,我写了这个脚本,115的优蛋实在是不能忍了
用法
1. 用浏览器将相应的帖子存盘,起名叫a.html, 这是因为如果不这样的话,付费的内容用脚本下载不下来.
2. 在同一个目录下运行这个脚本.
这个脚本只是挑第一个link下载,不会选择是联通还是电信.如果大家有兴趣,我以后再加上这个功能
这个脚本也不会报告错误,因为是我一次性用的脚本.不过大家如果有兴趣还是可以用一下的,115太烂了.
#!/usr/bin/perl -w
use strict;
use warnings;
use LWP::Simple;
use HTML:

inkExtor;
$| = 1;
open my $fh, ">>download.log";
my @urls ;
my @urls2;
my $download = 1;
sub cb {
my ($tag, %attr) = @_;
if ($tag eq 'a' && $attr{href} && $attr{href} =~ /115.com/) {
push @urls, $attr{href};
}
}
sub cb2 {
my ($tag, %attr) = @_;
if ($tag eq 'a' && $attr{href} && $attr{href} =~ /down_group/ ) {
push @urls2, $attr{href};
}
}
my $p = HTML::LinkExtor->new(\&cb);
$p->parse_file("a.html");
for my $u (@urls) {
print $fh "processing $u\n";
if ($download == 0) {
if ($u =~ 'e6a7to82#') {
$download = 1;
}
print $fh "dont download $u\n";
next;
}
#print "\n\ndoing $u...\n";
my $content = get ($u);
unless (defined($content)) {
warn "cannot get $u\n";
next;
}
my $p2 = HTML::LinkExtor->new(\&cb2);
$p2->parse($content);
#print $urls2[0],"\n";
$urls2[0] =~ /file=(.*)$/;
my $file = $1;
print $fh "downloading $file\n";
getstore($urls2[0],$file);
@urls2 = ();
}
该贴已经同步到 欢乐chylli的微博