<?php
class Rebot{
public function get_Http_Content($url,$https=true,$method='GET',$data=null){
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HEADER,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
if($https){
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);
}
if($method=='POST'){
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFILEDS,$data);
}
$content=curl_exec($ch);
curl_close($ch);
return $content;
}
}
$rebot=new Rebot();
$url = "http://www.baidu.com/s?wd=兰州";
echo $rebot->get_Http_Content($url);
?>
curl 爬虫网页
最新推荐文章于 2020-09-11 17:33:15 发布