如何判断网址是否被百度收录呢?
在网上找了很久,都是很久之间的代码,基本不能正常使用了,经过本人测试验证,以下代码可以正常使用。
function BD_cURL($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.baidu.com/s?wd=' . $url . ''); $httpheader[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; $httpheader[] = "Accept-Encoding: gzip, deflate, sdch, br"; $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8"; curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.3"); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); curl_close($ch); if (!strpos($ret, '>百度为您找到相关结果约')) { return false; } if (!strpos($ret, '>提交网址')) { return true; } else { return false; } } echo BD_cURL('https://www.yqll.com/');