Is there a way to let cURL wait until the page's dynamic updates are done?

前端 未结 3 1550
梦谈多话
梦谈多话 2020-12-11 03:04

I\'m fetching pages with cURL in PHP. Everything works fine, but I\'m fetching some parts of the page that are calculated with JavaScript a fraction after the page is loaded

3条回答
  •  感动是毒
    2020-12-11 03:46

    cURL does not execute any JavaScript or download any files referenced in the document. So cURL is not the solution for your problem.

    You'll have to use a browser on the server side, tell it to load the page, wait for X seconds and then ask it to give you the HTML.

    Look at: http://phantomjs.org/ (you'll need to use node.js, I'm not aware of any PHP solutions).

提交回复
热议问题