如何获得一个网站一个JavaScript / AJAX -loaded格的内容? [英] How to get content of a javascript/ajax -loaded div on a site?

查看:167
本文介绍了如何获得一个网站一个JavaScript / AJAX -loaded格的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

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

这篇关于如何获得一个网站一个JavaScript / AJAX -loaded格的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆