只管下载,没有去理会细节上的事情,所以很多毛病可以挑~
环境:This is perl, v5.10.1 built for MSWin32-x86-multi-thread
(with 2 registered patches, see perl -V for more detail)
另外由于perl学的不精,借用wget .... - $main="http://www.zhuoku.com";
- $somepage="http://www.zhuoku.com/zhuomianbizhi/dong/index-1.htm";
- system("wget -O a.txt $somepage");
- open READ,"<a.txt";
- foreach (<READ>) {
- if (/div class="bizhiin"/) {$line=$_;}
- }
- close READ;
- @test=split("</a>",$line);
-
- $startYN=0;
-
- foreach (@test) {
- if (/img src/) {
- /href="([^"]+)".*alt="(.*)"/;
- print "$1 $2\n";
- $name=$2;
- system("wget -nc $main$1");
- $str=$1;
- $str=~s/.htm/\(1\).htm/;
- system("wget -nc $main$str");
- $str=~s/[^\/]+.htm$//; #获取中间关键地址段
- $file=$&;
- &test;
- }
- }
- <STDIN>;
-
- sub test() {
- print "$name $main $str $file";
- open READ,"<$file";
- foreach (<READ>) {
- if (/\(2\).htm/) {
- /(\d+)<\/a><\/li><\/div><\/div>/;
- $end=$1;
- }
- }
- close READ;
- mkdir "$name";
- chdir "$name";
- foreach (1..$end) {
- $file=~s/\(\d+\)/\($_\)/;
- print "\n$file";
- if (! -e $file) {
- system("wget -nc $main$str$file");
- }
- &getpic();
- }
- chdir "../";
- }
-
- sub getpic() {
- open READ,"<$file";
- $startYN+=1;
- $pan=$startYN % 4;
- foreach (<READ>) {
- if (/id="imageview" src="([^"]+)"/) {
- print "$1\n";
- if ($pan==0) {
- system("wget -nc $1");
- } else {
- system("start /min cmd /c wget -nc $1");
- }
- }
- }
- }
复制代码
|