php 获取 远程 内容
目标:http://www.lecai.com/lottery/draw/ajax_get_latest_draw_html.php?lottery_type=544fi...
目标:http://www.lecai.com/lottery/draw/ajax_get_latest_draw_html.php?lottery_type=544
file_get_contents 用这个方法不行
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
用这个方法没有出现错误,但是没有输出任何内容
请前辈指教,我要获取他的代码 然后匹配出开奖号码 谢谢前辈!
特奉上白银50两!解决之后另有酬谢! 展开
file_get_contents 用这个方法不行
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
用这个方法没有出现错误,但是没有输出任何内容
请前辈指教,我要获取他的代码 然后匹配出开奖号码 谢谢前辈!
特奉上白银50两!解决之后另有酬谢! 展开
3个回答
追问
什么代码呢
追答
<?php
$url = "http://www.lecai.com/lottery/draw/ajax_get_latest_draw_html.php?lottery_type=544";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
展开全部
<?php
$url="http://www.lecai.com/lottery/draw/ajax_get_latest_draw_html.php?lottery_type=544";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 5);
$code = curl_exec($ch);
$code=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'GBK', pack('H4', '\\1'))", $code);
$code=str_replace("\\","",$code);
curl_close($ch);
print_r($code);
?>
$url="http://www.lecai.com/lottery/draw/ajax_get_latest_draw_html.php?lottery_type=544";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 5);
$code = curl_exec($ch);
$code=preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'GBK', pack('H4', '\\1'))", $code);
$code=str_replace("\\","",$code);
curl_close($ch);
print_r($code);
?>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)');
加上这句,伪装成浏览器会增加成功率.
加上这句,伪装成浏览器会增加成功率.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询