#!/usr/bin/perl -w
# This script is used to count the numbers of page vIEws of tudou's yinyue item.
use strict;
use LWP::Simple;
use Encode;
my $num;
my $total;
my @nums = (1..50);
foreach my $num (@nums) {
my $url = "http://music.tudou.com/labeltop/zcakqzfjz19zdwyq_s0p$num.html"; my $file = "output"; open (my $out,'>',"$file"); my $contents = get($url); $contents = encode_utf8($contents); print $out $contents; close $out; open (my $in,'<',"$file") or dIE "can't open file $file: $!\n"; while (<$in>) { next unless /播放/ and /播客/; /.*<li>播放: ([\d|,]*\d+)<\/li>.*/; $num = $1; $num =~ s/,//g; my $filetmp = "tmpfile"; open (my $tmpfile,'>>',"$filetmp") or dIE "can't open file $filetmp: $!\n"; print $tmpfile "$num\n"; $total += $num; } close $in; } print "$total\n";
以上是内存溢出为你收集整理的perl LWP::Simple分析土豆视频点击量全部内容,希望文章能够帮你解决perl LWP::Simple分析土豆视频点击量所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)