

Go开发工程师:迎接上升风口,踏入蓝海行业!
source link: https://studygolang.com/articles/34889
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

download:Go开发工程师:迎接上升风口,踏入蓝海行业!
//实现使用curl模拟百度蜘蛛进行采集
class Curlcontent{
protected function _GetContent( $url )
{
$this->ch = curl_init();
$this->ip = '220.181.108.'.rand(1,255); // 百度蜘蛛
$this->timeout = 15;
curl_setopt($this->ch,CURLOPT_URL,$url);
curl_setopt($this->ch,CURLOPT_TIMEOUT,0);
//伪造百度蜘蛛IP
curl_setopt($this->ch,CURLOPT_HTTPHEADER,array('X-FORWARDED-FOR:'.$this->ip.'','CLIENT-IP:'.$this->ip.''));
//伪造百度蜘蛛头部
curl_setopt($this->ch,CURLOPT_USERAGENT,"Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)");
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->ch,CURLOPT_HEADER,0);
curl_setopt($this->ch,CURLOPT_CONNECTTIMEOUT,$this->timeout);
curl_setopt($this->ch,CURLOPT_SSL_VERIFYPEER,false);
$content = curl_exec($this->ch);
if($content === false)
{//输出错误信息
$no = curl_errno($this->ch);
switch(trim($no))
{
case 28 : $this->error = '访问目标地址超时'; break;
default : $this->error = curl_error($this->ch); break;
}
echo $this->error;
}
else
{
$this->succ = true;
return $content;
}
}
public function getcurl($url){
return $this->_GetContent($url);
}
}
$api = "https://www.maihuangjin.com/mobile/";
$Curlcontent = new Curlcontent();
$data = $Curlcontent->getcurl($api);
有疑问加站长微信联系(非本文作者)

Recommend
-
47
共享单车ofo最近的搞的"事"有点多。 先是抵押家产式的借钱,在新加坡打出挖币广告,看起来比较靠谱的事便是整顿了运营业务,5月初,of...
-
49
摩根大通近日推出加密货币J PM Coin ,这使得摩根大通成为第一家发行加密货币的全球主流金融机构。 在链捕手 ...
-
30
教龄1年,是一个新鲜热乎的新老师。有以下经验,谈不上发现:1.抖音上流行的班主任进入班级前后反差并没…
-
29
程序员 - @jianfa2003 -
-
39
【猎云网(微信:)】10月5日报道(编译:小猪配齐) 关于“Uber进入按需招聘”这一传言已经有一段时间了,但Uber今天正式坐实,表示...
-
45
为什么从事产品?你对产品经理的理解是什么?为什么选择这个行业或企业?这几个问题在产品入行时大概率都会被提问。 这些问题的答案,是我们最开始对产品的认知。在踏入产品多年后,我又重新回过头来思考这些问题,有没有一个...
-
3
迎接最「聪明」的风口,为脑与神经科学勇敢投资 如果说宇宙是复杂、神秘又迷人的,大脑也同样如此。 ...
-
7
撬动千亿蓝海市场,AR-HUD站上“风口”-汽车电子-与非网 经过...
-
4
为何万亿氢能“蓝海”再上风口? 20小时前 作者:锂解 X 芝能 阅读需 1 分钟 加入交流群...
-
6
2023全新版Go开发工程师完结(风口上的技术) biancheng1 · 9天之前 · 37...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK