Home > php教程 > php手册 > PHP判断url链接是否被百度收录

PHP判断url链接是否被百度收录

WBOY
Release: 2016-06-07 11:34:55
Original
959 people have browsed it

PHP判断url链接是否被百度收录
百度找了几个检测url的方法,都不能正确显示是否被收录。还好本人用过wordpress,把wordpress的检测url链接是否被百度收录的方法分享给大家。本人已测过,正确率100%。
下面以http://www.heimaolianmeng.com/heimaoseojishu/index.html为例演示:
PHP判断url链接是否被百度收录

用到的:
function checkBaidu($url) {
$url = 'http://www.baidu.com/s?wd=' . urlencode($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 -1;
}
}


后台检测url是否被百度搜索引擎收录。若返回1,说明已被收录,你可以点击查看该链接收录情况。否则返回-1.说明没有被收录,你可以提交到站长工具。
$url = trim($_POST['url']);
echo checkBaidu($url);
后面将介绍其他搜索引擎的收录情况,比如google,360,搜狗,bing等,敬请期待!

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template