抓捕腾讯音乐MV前100页的点击量
[root@dou ~]# cat 2.pl
#!/usr/local/bin/perl
use strict;
use Web::Scraper;
use URI;
my $num;
my $total;
my @pathnums = (0..99);
my @xpathnums = (1..28);
my @firstnums = (0..9) x 10;
my $firstnum = 0;
my $file = "tengxun";
my $i = 0;
foreach my $pathnum (@pathnums) {
??????? my $html = "http://v.qq.com/mvlist/$firstnums[$firstnum]/22_-1_-1_-1_-1_1_$pathnum_0_28.html";
??????? my $uri = URI->new($html);
??????? foreach my $xpathnum (@xpathnums) {
??????????????? my $xpath = "//*[@id="content"]/ul/li[$xpathnum]/p[2]/span";
??????????????? my $scraper = scraper {
??????????????????? process "$xpath",'key' => 'TEXT';
??????? };
??????????????? my $result = $scraper->scrape($uri);
??????????????? $num = $result->{key};
??????????????? open (my $fh,'>>',"$file") or die "can't create file $file: $!n";
??????????????? print "hello $i++n";
??????????????? print $fh "$pathnum ------ $xpathnumn";
??????????????? print $fh "$numn";
??????????????? $total += $result->{key};
??????? } ??????? $firstnum += 1; } print "$totaln";