1

I am trying to extract data from a website using Perl. Below is the description of the site:

  • site displays data dependent on a date
  • a calendar is displayed that is used to change the date
  • upon clicking the dates in the calendar, it calls a javascript function that passes in the date and refreshes the part of the page that displays the data

My question is, how do I execute that JS function so that I could loop through the dates that I need data from?

Thanks in Advance

2 Answers 2

3

It's much easy make same HTTP request from your script and get all data you need directly.

You can record all HTTP requests/responses of your browser by using HTTP Fox extension (for Firefox).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help. I downloaded HTTPFox and knew the exact request the site made. I imitated this request using LWP and it works perfectly. Thanks again!
2

Edit

There is a CPAN module:

JavaScript - Perl extension for executing embedded JavaScript

But I've not already tested them.

Original post:

Take a look at smjs it's Spidermonkey's JS shell.

You could pass javascript by:

open my $jsout,"echo '$javascript' | smjs |" or die;
print <$jsout>;

...

But be care! This take security consideration away!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.