Home > Backend Development > PHP Tutorial > php-PHP判断url链接是否被百度收录

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

WBOY
Release: 2016-06-02 11:27:44
Original
1301 people have browsed it

php

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

用到的:
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);

批量URL查询并显示的怎么写?

Related labels:
php
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template