简体   繁体   English

如何使用Perl的WWW :: Mechanize获取帧源?

[英]How can I get the frame source with Perl's WWW::Mechanize?

Using WWW::Mechanize::Firefox, I can get the source of the page I visited. 使用WWW :: Mechanize :: Firefox,我可以获得我访问过的页面的来源。 However, if the page contains a frame, I get the frame tag and not the actual source of the page that is loaded. 但是,如果页面包含一个框架,我会得到框架标签,而不是加载的页面的实际来源。 Mechanize::Frames seems to be what I am looking for. Mechanize :: Frames似乎就是我想要的。 Is there a way to use them together? 有没有办法一起使用它们?

That's probably because you're not loading the frame contents. 这可能是因为你没有加载帧内容。

$mech->follow_link(tag => "frame"); # open first frame in document
my $src = $mech->content;

要获得帧HTML源,只需通过->selector()->xpath()获取该帧,然后使用$frame->{innerHTML}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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