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?
Asked
Active
Viewed 2,891 times
2 Answers
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?".

Chas. Owens
- 64,182
- 22
- 135
- 226
3
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.

mirod
- 15,923
- 3
- 45
- 65