登录
立即注册
首页
>
绿虎论坛
>
历史版块
>
编程
>
PHP
>
讨论/求助
file_get_contents有问
大杨
@Ta
2012-06-21
1554点击
如何在使用file_get_contents远程获取其它网址页面字符串前声明要调用的是wap网页?因为目标电脑和WAp页面都不相同~
隐藏样式
查看源码
回复列表(3|
隐藏机器人聊天
)
1
唯美无殇
@Ta
/ 2012-06-21 /
样
/
源
2
老虎会游泳
@Ta
/ 2012-06-21 /
样
/
源
使用CONTEXT添加HTTP的Accept头来声明自己只支持WAP网页
3
老虎会游泳
@Ta
/ 2012-06-21 /
样
/
源
<?php
$opts = array(
'http' => array(
'method' => "GET" ,
'header' => "Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8,text/vnd.wap.wml;q=0.6\r\n"
)
);
$context = stream_context_create ( $opts );
echo file_get_contents ('
http://www.example.com
' , false, $context);
?>
添加新回复
回复需要
登录
。
$opts = array(
'http' => array(
'method' => "GET" ,
'header' => "Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8,text/vnd.wap.wml;q=0.6\r\n"
)
);
$context = stream_context_create ( $opts );
echo file_get_contents ('http://www.example.com' , false, $context);
?>