实用代码 | 判断文章被百度 360 搜狗收录的办法

【摘要】使用方法:首先在模板下的module.php中添加以下代码判断内容页是否百度收录代码:<?php//判断内容页是否百度收录functionbaidu($url){$url='http://www.baidu.com/s?wd='.$url;...

使用方法首先在模板下的module.php 中添加以下代码

判断内容页是否百度收录代码:

 <?php
//判断内容页是否百度收录
function baidu($url){
$url='http://www.baidu.com/s?wd='.$url;
$curl=curl_init();curl_setopt($curl,CURLOPT_URL,$url);curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);$rs=curl_exec($curl);curl_close($curl);if(!strpos($rs,'没有找到')){return 1;}else{return 0;}}

function logurl($id){$url=Url::log($id);
if(baidu($url)==1){echo "<a style=\"color:#1EA83A;\" rel=\"external nofollow\" title=\"点击查看!\" target=\"_blank\" href=\"http://www.baidu.com/s?wd=$url\">[百度已收录]</a>";
}else{echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\">[百度未收录]</a>";}}
?>
判断内容页是否360收录代码:
<?php
//判断内容页是否360收录
function haoso($url){
$url='https://www.so.com/s?a=index&q='.$url;
$curl=curl_init();curl_setopt($curl,CURLOPT_URL,$url);curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);$rs=curl_exec($curl);curl_close($curl);
if(!strpos($rs,'找不到')){
return 1;}
else{return 0;}}

function logurlhaoso($id){$url=Url::log($id);
if(haoso($url)==1){echo "<a style=\"color:#1EA83A;\" rel=\"external nofollow\" title=\"点击查看!\" target=\"_blank\" href=\"https://www.so.com/s?a=index&q=$url\">[360已收录]</a>";
}else{echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://info.so.com/site_submit.html\">[360未收录]</a>";}}
?>
判断内容页是否搜狗收录代码:
<?php
//判断内容页是否搜狗收录
function sogou($url){
$url='https://www.sogou.com/sie?query='.$url;
$curl=curl_init();curl_setopt($curl,CURLOPT_URL,$url);curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);$rs=curl_exec($curl);curl_close($curl);
if(!strpos($rs,'未收录?')){
return 1;}
else{return 0;}}
function logurlsogou($id){$url=Url::log($id);
if(sogou($url)==1){echo "<a style=\"color:#1EA83A;\" rel=\"external nofollow\" title=\"点击查看!\" target=\"_blank\" href=\"https://www.sogou.com/sie?query=$url\">[搜狗已收录]</a>";
}else{echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://fankui.help.sogou.com/index.php/web/web/index/type/1?v=1&urlword=$url\">[搜狗未收录]</a>";}}
?>

    以上代码放入module.php中, 调用挂载代码:

        百度:<?php echo logurl($logid);?>

        360:<?php echo logurlhaoso($logid);?> 

        搜狗:<?php echo logurlsogou($logid);?> 

    将上述代码添加到echo_log.php的合适位置即可

 小东
 简介:专业团队网站开发、安全运维,合作意向请联系!

扫码关注微信公众号:ITDYBOY,学前端,学安全,从0到1,从1到精通!

扫码关注微信公众号:ITDYBOY

发表评论

游客
送你一朵小花花~

帅人已评(16)

我使用 360与搜狗 ,不管收录与否,全部显示已收录!
LV 4 A逍遥 7年前 (2017-04-30) 回复
@A逍遥:嗯?可能接口问题?或者是在文章调用的位置不对~
站长已认证 小东 7年前 (2017-04-30) 回复
可以[调戏]
LV 1 閑趣生 7年前 (2017-02-02) 回复