How can I use Perl to scrape a website that reveals its content with JavaScript?

前端 未结 4 1007
南方客
南方客 2020-12-11 10:54

I need to write a Perl script to scrape a website. The website can only be scraped with JavaScript, and the user is on Windows.

I got some way with Win32::IE::Mech

4条回答
  •  攒了一身酷
    2020-12-11 11:24

    WWW::Selenium.

    • It allows you to specify which browser to use (IE and Firefox are supported from the get-go)
    • It supports access to elements via xpath elements, table IDs, text (regex-matching!) and URLs
    • It provides a Swiss army knife of user-interaction options, giving you flexibility over how you wish to simulate end-user browsing

    You'll need to download the Selenium Remote Control and have it running in the background for the module to work.

    It may not be a good option if your page load times are unpredictable.

提交回复
热议问题