Home >Backend Development >PHP Tutorial > 模拟浏览器也没法获取远程网页内容!求解

模拟浏览器也没法获取远程网页内容!求解

WBOY
WBOYOriginal
2016-06-13 13:06:59845browse

模拟浏览器也无法获取远程网页内容!求解
最近发现国外的一个网站,不知是做了什么技术,搅尽脑汁,使用了各种办法,就是无法获取远程内容。烦请大神们帮忙分解一下?下面是例子

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php $url = 'http://www.hahasport.com/v-4/6/112/v-471310.html';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_REFERER, 'http://www.frombar.tv/'); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)');  // 设置选项,浏览器信息
$raw = curl_exec($ch);  // 执行
curl_close($ch);  // 关闭handler
echo $raw;  // 输出结果
?>



上面模拟浏览器,报错是无法找到页面,但 http://www.hahasport.com/v-4/6/112/v-471310.html 实际上是可以再浏览器里面打开的

实在是不解啊,按理说用浏览器能访问,用程序模拟浏览器应该也可以访问啊,怎么就无法找到网页了?

 烦请大神帮忙分解分解啊

------解决方案--------------------
加个选项试试看
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate,sdch');
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn