<?php function checkBaiduInclude($url){ $url = 'http://www.baidu.com/s?wd='.$url; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); if(strpos($result, '没有找到该URL')){ return 0; }elseif(strpos($result, '抱歉没有找到')){ return 0; }elseif(strpos($result, '请检查您的输入是否正确')){ return 0; }elseif(strpos($result, '网页未收录')){ return 0; }else{ return 1; } } $url = "https://www.hubaye.com"; if(checkBaiduInclude($url) == 1){ var_dump("该网页已经被百度收录了"); }else{ var_dump("该网页还没有被百度收录"); }
标签: PHP