开发者

Scrape a page with AJAX requests

开发者 https://www.devze.com 2023-03-08 16:00 出处:网络
I\'m usin开发者_运维百科g Node.js with jsDOM to scrape web pages and execute JavaScript in them. But if a page contains AJAX requests, they are not executed.

I'm usin开发者_运维百科g Node.js with jsDOM to scrape web pages and execute JavaScript in them. But if a page contains AJAX requests, they are not executed.

Is there an option to execute AJAX calls inside the scraped pages?


you need to emulate XMLHTTPRequests. Here's an abstraction. They don't work out of the box in node.js.

You will have to figure out how to get it to talk to jsdom. (Hopefully just appending a xmlhttprequest constructor to the window will fix it)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号