Link Harvester - 如何使用Perl收集YouTube视频ID?

时间:2011-04-20 09:12:07

标签: perl

好的,这就是我想做的事情

use lwp;
my $ua ="mozzila";
my $search = ua->get("http://www.youtube.com/results?search_query=funny+video&aq=f")->content;

while ($search =~m,# ok i do not know what i must put here,sgi)
{
print "$1/n";
}

这就是全部。有人可以帮助我..

2 个答案:

答案 0 :(得分:1)

while ($search =~ m/href="\/watch\?v=([a-zA-Z0-9_-]+)"/) {
    print "$1\n";
}

答案 1 :(得分:0)

use LWP::Simple;
print $_."\n" for (get("http://www.youtube.com/results?search_query=funny+video&aq=f") =~ m/href="\/watch\?v=([a-zA-Z0-9_-]+)"/g);