代码如果,就是模拟浏览器,怎么实现点击指定内容,求会的帮忙完善下
<?php
$url = "http://www.baidu.com/s?wd=%E6%96%B0%E8%A5%BF%E5%85%B045%E7%A7%92%E5%BD%A9%E8%AE%A1%E5%88%92";
// 构造包头,模拟浏览器请求
$header = array (
"Host:www.baidu.com",
"Content-Type:application/x-www-form-urlencoded",//post请求
"Connection: keep-alive",
'Referer:dlysjc.com',
'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; BIDUBrowser 2.6)'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $header );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
// dlysjc.com执行
$content = curl_exec ( $ch );
if ($content == FALSE) {
echo "error:" . curl_error ( $ch );
}
// dlysjc.com关闭
curl_close ( $ch );
//dlysjc.com输出结果
echo $content;
?>
|