get(动态加载页面)内容使用PHP / CURL? [英] get (dynamic loading page) contents using PHP/CURL?

查看:366
本文介绍了get(动态加载页面)内容使用PHP / CURL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用PHP / CURL编程的webboot,但我面临一个问题,处理一个特定的页面,它正在加载一些内容动态! .. 解释更多
当我尝试使用PHP / CURL下载页面,我没有得到一些内容!然后我发现这个内容加载后页面加载。这是为什么CURL不处理这些错过的内容。

I try to program a webboot using PHP/CURL, but I face a problem in handling a specific page that it's loading some contents dynamically !! .. to explain more : when I try to download the page using PHP/CURL, I do not get some contents ! then I discovered that this contents are loaded after page is loaded. and this is why CURL does not handle these missed contents.

可以帮助我!

代码是:

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $reffer);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $redirect);
    curl_setopt($ch, CURLOPT_COOKIEFILE, ABSOLUTE_PATH."Cookies/cookies.txt");
    curl_setopt($ch, CURLOPT_COOKIEJAR, ABSOLUTE_PATH."Cookies/cookies.txt");
$result = curl_exec($ch);


推荐答案

您尝试加载什么网址?可能是您请求的页面有一个或多个AJAX请求,在事实后加载内容。我不认为cURL可以通过AJAX或其他XHR请求来容纳运行时加载的信息。

What URL are you trying to load? It could be that the page you're requesting has one or more AJAX requests that load content in after the fact. I don't think that cURL can accomodate runtime-loaded information via AJAX or other XHR request.

你可能想看看像 PhantomJS ,它是一个无头的WebKit浏览器,它将完全执行页面并返回动态组装的DOM。

You might want to look at something like PhantomJS, which is a headless WebKit browser which will execute the page fully and return the dynamically assembled DOM.

这篇关于get(动态加载页面)内容使用PHP / CURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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