PHP implementation Check whether the article is Baidu included _php skills

Source: Internet
Author: User

Site has a background, the background to publish news and products, after the hair if you want to see whether the page has been included in Baidu, but also through third-party tools or directly to Baidu search. Recently in doing SEO, every day to see the previous article has not been included, on this job is a very cumbersome work. So I found a piece of code on the Internet, through the address can know whether there is no Baidu included, is very convenient.


the following is the PHP code

Copy Code code as follows:

function Checkbaidu ($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);
$arr = Parse_url ($url);
if (Strpos ($arr [' Query '], ' http://')) {
$arr [' query '] = str_replace (' http://', ', ', Str_replace (' wd= ', ', ', $arr [' query ']);
} else {
$arr [' query '] = Str_replace (' wd= ', ', ', $arr [' query ']);
}
if (Strpos ($arr [' Query '], '? ')) {
$str = strstr ($arr [' Query '], '? ');
$arr [' query '] = Str_replace ($str, ', $arr [' query ']);
}
if (Strpos ($arr [' Query '], '/')) {
$narr = explode ('/', $arr [' query ']);
$arr [' query '] = $narr [0];
}
if (Strpos ($rs, '. $arr [' query '].]) {
return 1;
} else {
return 0;
}
}
echo Checkbaidu (' www.jb51.net ');

Back to 1 of the results included. is not included in the 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.