file_get_contents取不到内容 下面这个地址我用file_get_contents取不到内容,而在浏览器里是可以打开的$content=file_get_contents('http://istock.jrj.com.cn/d/ht/hottopic1.html'); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 php.ini 的 allow_url_fopen 有没有打开看看防火墙有没冇封锁 php.ini里面allow_url_fopen 是否为on如果不是,重启apache. 没有防火墙,allow_url_fopen 也是开的另外,别的页面都可以取到的,就这个页面取不到 看看allow_url_fopen 打开没有 我试了...它的服务器限制了header你header 一定要指的的一些 User-Agent 才给下载否则 HTTP 503 $queryURL = "http://istock.jrj.com.cn/d/ht/hottopic1.html"; //user_agent $useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"; //伪造header $header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache'); $ch = curl_init(); curl_setopt($ch, CURLOPT_REFERER, $queryURL); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); curl_setopt($ch, CURLOPT_USERAGENT, $useragent);curl_setopt($ch, CURLOPT_URL,$queryURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); echo $result; 用这种方式获取吧.应该是对方服务器做了限制.用file_get_contents类函数返回HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable错误,MS是 服务器由于维护或者负载过重未能应答.用浏览器可以,只能伪造useragent了. php.ini里面 allow_url_fopen 是否为on 如果不是,重启apache. $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"User-Agent: Mozilla/5.0\n" ));$context = stream_context_create($opts);echo file_get_contents("http://istock.jrj.com.cn/d/ht/hottopic1.html",false,$context); 熟悉PHP和js,ajax的高手请进!这样的页面怎么实现?!给个思路,或重金悬赏! 谁能找到php+ajax 文件上传 获取返回值的例子么?急.。。。 php支持mysql的问题 请问如何快速得到某个元素在数列中的下标值 各位大侠,小弟求一正则表达式 武汉弘毅互联网络技术有限公司 为什么sql 里有点 ?? php 生成 html 速度问题 请教 本人有一语句在sqlserver可以实现,但在不能在mysql不能实现,请帮忙 安装WampServer出现的问题 高分求正则解释 serialize与unserialize
看看防火墙有没冇封锁
allow_url_fopen 是否为on
如果不是,重启apache.
另外,别的页面都可以取到的,就这个页面取不到
你header 一定要指的的一些 User-Agent 才给下载
否则 HTTP 503
$queryURL = "http://istock.jrj.com.cn/d/ht/hottopic1.html";
//user_agent
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
//伪造header
$header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache');
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, $queryURL);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_URL,$queryURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo $result; 用这种方式获取吧.
应该是对方服务器做了限制.
用file_get_contents类函数返回HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable错误,MS是
allow_url_fopen 是否为on
如果不是,重启apache.
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: Mozilla/5.0\n"
)
);
$context = stream_context_create($opts);
echo file_get_contents("http://istock.jrj.com.cn/d/ht/hottopic1.html",false,$context);