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.