使用AngularJS读取和处理html [英] Reading and processing html with AngularJS
问题描述
我的perl程序通过get(URL)读取网页并处理数据.
My perl program reads (by get(URL) ) web pages and processes the data.
这很好用,但是最近我有了AngularJS的网页.
This works fine but recently I got an web page with AngularJS.
这意味着get(URL)不会传递完成的内容,因为AngularJS代码会更改浏览器中传递的html内容.
This means get(URL) does not deliver the completed content because the AngularJS code changes the delivered html content within the browser.
是否有一种获取完整内容的方法.F.i.通过将代码发送到浏览器模块?
Is there a way to get the completed content. F.i. by sending the code to a browser module?
谢谢,柯斯(W. Curth)
Thanks, W. Curth
推荐答案
您可以使用 WWW:Mechanize :: Firefox 来获取呈现的页面.
You could use WWW:Mechanize::Firefox to get the rendered page.
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get( $url, ':content_file' => $tempfile );
print $mech->content( format => 'html' );
如果它不起作用,则可以执行自定义JS代码或处理DOM树.
If it is not working you could execute a custom JS code or process the DOM tree.
这篇关于使用AngularJS读取和处理html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!