How to get content of a javascript/ajax -loaded div on a site?

后端 未结 5 1530
滥情空心
滥情空心 2021-02-09 12:40

I have a PHP-script that loads page-content from another website by using CURL and simple_html_dom PHP library. This works great. If I echo out the HTML returned I can see the d

5条回答
  •  终归单人心
    2021-02-09 13:23

    Unfortunately Javascript is run client-side, in a browser, so unless the page is loaded in a web browser there is no simple way to do it.

    The only way I can think of, is having a browser running in a server’s background, reloading and saving the generated page automatically in a file which will be available for a PHP script to fetch. Well... I don’t know about anyone who has implemented such an idea.

    Better try to get the URL where the div is being populated from. If the div contents are generated through AJAX for example, maybe if you fetch the data-origin URL with cURL, the data will be available for you as well.

提交回复
热议问题