1
我想从第1184到1325行的http://www.soccerbase.com/tournaments/tournament.sd?comp_id=1中抓取信息,基本上是未来7天即将到来的游戏。我的代码只针对一个实例工作,但我无法弄清楚如何迭代代码,以便它能够清除所有游戏信息,直到它达到7天的游戏价值。是否有某种形式的循环,我可以创建,将刮,直到我打到某个标签或什么?这是我的代码迄今为止,在此先感谢!WWW ::机械化和迭代
my $page = WWW::Mechanize->new;
$page->get('http://www.soccerbase.com/tournaments/tournament.sd?comp_id=1');
my $stream = HTML::TokeParser->new(\$page->{content});
my @fixture;
my $tag = $stream->get_tag("td");
while($tag->[1]{class} ne "dateTime"){
$tag = $stream->get_tag("td");
}
if ($tag->[1]{class} eq "dateTime") {
push(@fixture, $stream->get_trimmed_text("/a"));
}
$stream->get_tag("a");
$stream->get_tag("a");
push(@fixture, $stream->get_trimmed_text("/a"));
$stream->get_tag("a");
push(@fixture, $stream->get_trimmed_text("/a"));
foreach $element (@fixture){
print $element, "\t";
}
print "\n";
非常感谢,这个完美的作品。还有一个问题,如果你不介意,我将如何从上述结构中提取团队名称和日期,以将它们放在正常的字符串变量中?再次感谢! – blacky 2012-03-13 19:26:30
[打开一个新问题](http://stackoverflow.com/questions/ask)。 – daxim 2012-03-13 19:35:51
好的,我已经这么做了! – blacky 2012-03-13 20:53:21