搜索

首页  >  问答  >  正文

curl抓取页面之前都比较稳定,后来就输出空页面了

http://live.500.com/2h1.php

这个是地址。构造过ip  来路 和浏览器标示头文件等,请问各位大佬这个要怎么才能抓取到这个网址

function curl_file_get_contents_nossl($durl){

$r = rand(80,255);

$useragent = array(

'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)',

'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)',

'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',

'Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1',

'Opera/9.27 (Windows NT 5.2; U; zh-cn)',

'Opera/8.0 (Macintosh; PPC Mac OS X; U; en)',

'Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13 ',

'Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13'


);

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, "gzip,deflate");

  curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:28.58.88.'.$r, 'CLIENT-IP:225.28.58.'.$r));  //构造IP 

  curl_setopt($ch, CURLOPT_URL, $durl);

  curl_setopt($ch, CURLOPT_REFERER, "http://live.500.com/");   //构造来路 

  curl_setopt($ch, CURLOPT_TIMEOUT, 5);

  curl_setopt($ch, CURLOPT_USERAGENT, array_rand($useragent));

  //curl_setopt($ch, CURLOPT_REFERER,_REFERER_);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书下同

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

  $r = curl_exec($ch);

  curl_close($ch);

  return $r;

}


-Yang-Yang1902 天前1214

全部回复(1)我来回复

  • -Yang

    -Yang2019-09-14 13:46:51

    已经解决了,就是数据太多了,,,,

    回复
    0
  • 取消回复