如何获得一个网站一个JavaScript / AJAX -loaded格的内容?如何获得、内容、网站、JavaScript

2023-09-10 13:33:11 作者:浪战

我有一个PHP脚本,通过使用卷曲和simple_html_dom PHP库加载从其他网页内容。这个伟大的工程。如果我呼应了返回的HTML我可以看到DIV-内容在那里。

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 div-content there.

不过,如果我尽量只选择分度simple_html_dom,股利总是返回空。起初我不知道为什么。现在我知道,这是因为它的内容显然是填充的JavaScript / AJAX。

However, if I try to select only that div with the simple_html_dom, the div always returned empty. At first I didn't know why. Now I know that it's because its content apparently is populated with javascript/ajax.

我该如何获得网站的内容,然后可以选择div内容后的JavaScript已经填充了正确的内容?

How would I get the content of the site and then be able to select the div-content AFTER the javascript has populated it with the correct content?

它甚至有可能吗? 谢谢!

Is it even possible? Thanks!

推荐答案

是它的一块蛋糕,如果你只是在一个由AJAX返回的特定HTML兴趣。

Yes its piece of cake if you are interested only in that particular html which is returned by ajax.

在收集类似的URL,参数和请求类型(POST / GET)从Ajax请求的信息。 生成从PHP /卷曲code相同的请求,你得到了它。 在希望与服务器逻辑将不检查谁发送的请求。