[英]Wait for a post to appear using WWW::Mechanize::Firefox
I´m trying to get the information within the item-contents divisions of the webpage and i would like my script to wait and read any new item-content divisions appearing in the webpage. 我正在尝试在网页的项目内容部分中获取信息,我希望我的脚本能够等待并读取网页中出现的所有新的项目内容部分。 Any suggestions?
有什么建议么?
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('https://openbook.etoro.com/Dellos/overview/');
my @text = $mech->selector('.item-content');
for my $p (0..$#text) {
my $normal=$text[$p]->{innerHTML};
print $normal;
}
exit;
Here is a very simple implementation. 这是一个非常简单的实现。 Before using this please follow @ThisSuitIsBlackNot suggestion to make sure it is Ok to do this.
在使用此功能之前,请遵循@ThisSuitIsBlackNot建议以确保可以执行此操作。
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
my %seen;
while (1){
$mech->get('https://openbook.etoro.com/Dellos/overview/');
my @text = $mech->selector('.item-content');
for my $p (0..$#text) {
next if $seen{$p};
my $normal=$text[$p]->{innerHTML};
print $normal;
$seen{$p} = 1;
}
sleep 30;
}
exit;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.