如何修改http_user_agent,把网页浏览器伪装成手机浏览器
本帖最后由 youritumei_habataku 于 2011-11-10 17:10:45 编辑 现在php里判断浏览器是否是手机浏览器的方法一般是:
如果是网页浏览器,他会加个代码,让他显示不出要显示的网页,我想问问php里面有没有可能修改自己的$_server['http_user_agent']值,把自己伪装成一个iphone等手机浏览器,从而在电脑上能获取这个网站的手机网页内容,我是这样获取代码的:
ob_start();
$ch = curl_init();
curl_setopt( $ch, curlopt_url, $url );
curl_setopt($ch, curlopt_returntransfer, 1);
curl_setopt($ch, curlopt_header, 0);
//curl_setopt( $ch, curlopt_post, 1 );
//curl_setopt( $ch, curlopt_postfields, $param );
//curl_exec( $ch );
//$retrievedhtml = ob_get_contents();
$retrievedhtml=curl_exec( $ch );
ob_end_clean();
curl_close( $ch );
谢谢
------解决方案--------------------
用firefox安装user agent switcher扩展,可以模拟手机发送ua头访问
------解决方案--------------------
sorry,没仔细看问题
$user_agent = 我是手机'';
curl_setopt($ch, curlopt_useragent, $user_agent);