链接收割机-如何使用Perl获取YouTube视频ID?
好吧,这就是我要做的链接收割机-如何使用Perl获取YouTube视频ID?,perl,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"; } 就这些。有人能帮我吗?你忘记了破折号和下划线
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";
}
就这些。有人能帮我吗?你忘记了破折号和下划线。
LWP
必须是大写Mozilla
大写,拼写为一个z
和两个l
。换行是用反斜杠写的,因此:\n
-编程教会你注意细节。
while ($search =~ m/href="\/watch\?v=([a-zA-Z0-9_-]+)"/) {
print "$1\n";
}
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);