Copy codeThe Code is as follows:
<? Php
/*
* Check whether Baidu has indexed the webpage curl Mode
* @ Param string $ url the input url
* Return int (1 is included, 0 is not included)
*/
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, '<B>'. $ arr ['query']. '</B> ')){
Return 1;
} Else {
Return 0;
}
}
Echo checkBaidu ('HTTP: // www.jb51.net /');
?>