繁体   English   中英

等待使用WWW :: Mechanize :: Firefox发布的帖子

[英]Wait for a post to appear using WWW::Mechanize::Firefox


我正在尝试在网页的项目内容部分中获取信息,我希望我的脚本能够等待并读取网页中出现的所有新的项目内容部分。 有什么建议么?

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;

这是一个非常简单的实现。 在使用此功能之前,请遵循@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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM