最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I get dynamically web content using Perl? - Stack Overflow

programmeradmin2浏览0评论

This is kind of tricky. There is this webpage which, I am guessing, uses some kind of AJAX to pull out content based on the search query. When I fetch the page using get in Perl, it fetches the script code behind the php/html, but not the results which are displayed when the query is searched manually. I need to be able to fetch the content of the results page. Is there anyway to do this in Perl?

This is kind of tricky. There is this webpage which, I am guessing, uses some kind of AJAX to pull out content based on the search query. When I fetch the page using get in Perl, it fetches the script code behind the php/html, but not the results which are displayed when the query is searched manually. I need to be able to fetch the content of the results page. Is there anyway to do this in Perl?

Share Improve this question edited Sep 8, 2009 at 5:56 Chas. Owens 65k24 gold badges139 silver badges232 bronze badges asked Sep 8, 2009 at 4:45 DeepakDeepak 2,0536 gold badges30 silver badges32 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Take a look at Selenium RC and the WWW::Selenium module in Perl. With them you can control a real web browser.

Another option is WWW::HtmlUnit which uses the HtmlUnit Java library to execute the JavaScript without a web browser. WWW::HtmlUnit uses Inline::Java to give Perl access to the library. I have found that when installing, it is best to say No to the question "Do you wish to build the JNI extension?".

If you are writing tests that need to check the rendered page, you can have a look at Schwern's javascript-tap-harness, which works with Selenium and handles all the scaffolding.

I also found Using WWW::Selenium To Test Or Automate An Ajax Website pretty useful.

发布评论

评论列表(0)

  1. 暂无评论