做个记录备份一下。
以下函数主要用到curl,so,主机必须开启curl支持,否则将无法正常使用。
- function so_360($url){
- $url='https://www.so.com/s?q='.$url;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- $res=curl_exec($curl);
- curl_close($curl);
- if(strpos($res,'找不到该URL')){
- return 1;
- } else {
- return 0;
- }
- }
- $check_urls=array(
- "http://www.cdsy.xyz/computer/servers/iis/20200830/cd15987831294572.html",
- "http://downloads.cdsy.xyz/software/windows_soft/chat/chat_tools/20201031/dd160410745433.html",
- "http://guoxue.cdsy.xyz/wmwh/gdkx/20200904/gx1599186870140.html"
- );
- foreach ($check_urls as $url){
- if(so_360($url) == 0) {
- echo '<p style="color:green;">已收录此链接:<a target="_blank" href="https://www.so.com/s?q='.$url.'">'.$url.'</a></p>';
- } else {
- echo '<p style="color:red;">未收录此链接:<a target="_blank" href="https://www.so.com/s?q='.$url.'">'.$url.'</a></p>';
- }
- }
注:仅限检测360搜索收录结果,百度、搜狗等理论上修改对应域名和搜索参数也可以,具体自测;
另:检测数量不要太多,否则耗时会很长;
还有,如果出现中文乱码,请在最上方加入:
- header("Content-type:text/html;charset=utf-8");