doufu9521 2016-02-04 13:26
浏览 24
已采纳

在simple_html_dom中设置超时

Can i set timeout for file_get_html() in simple_html_dom?

I need that this call wait for 5 sec. to render all scripts in a page.

Or another way to do this in PHP, parsing html pages using css selectors?

  • 写回答

1条回答 默认 最新

  • dongshan9619 2016-02-04 13:33
    关注

    You can not do that with simple_html_dom() or file_get_contents() or any other 'pure' PHP.

    For this purpose you have to use technologies like PhantomJS. Load the page into PhantomJS, wait for JavaScript to finish executing, then use the HTML that has been generated.

    PHP PhantomJS should make that quite simple (see the "Delay page render" example in the Documentation).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?