Home >Backend Development >PHP Tutorial >PHP implementation of querying Baidu and Google inclusion status (sample code)_PHP tutorial
I wrote a small thing to record the inclusion status of the site by Baidu and Google. Now I can query it. In fact, it is not difficult. I just go to file and download the remote file, and then analyze it.
By the way, it seems that the thing you need to check Google PR is just a file address, so it’s not difficult at all.
The complete code is as follows, file obtains the file, analyzes and outputs:
function baidudetail($domain) {
$baidu_site = 'http://www.baidu.com/baidu?word=site%3A' . $domain;
$baidu_link = 'http:// www.baidu.com/baidu?word=link%3A' . $domain;
$baidu_domain = 'http://www.baidu.com/baidu?word=domain%3A' . $domain;
getdetail($baidu_site, 'baidu_site', 'Related web pages', 'Articles, time spent');
getdetail($baidu_link, 'baidu_link', 'Related web pages', 'Articles, time spent');
getdetail( $baidu_domain, 'baidu_domain', 'related web pages', 'article, time');
}
function googledetail($domain) { function getdetail($url, $type, $wordf, $wordb) { function returndetail($content, $type) {
$google_site = 'http://www.google.cn/search?hl=zh-CN&q=site%3A' . $domain;
$google_link = ' http://www.google.cn/search?hl=zh-CN&q=link%3A' . $domain;
getdetail($google_site, 'google_site', ' results,', ' (Search time');
getdetail($google_link, 'google_link', 'about', ' link to '); //102
}
$pagecontent = @file($url);
$pagecontent = implode ('', $pagecontent);
$pagecontent = substr(strstr($pagecontent, $wordf), strlen($wordf));
$pagecontent = substr_replace($pagecontent, '', strpos($pagecontent, $wordb));
returndetail( $pagecontent, $type);
}
global $seodetail;
$seodetail[$type] = empty($content) ? 0 : $content;
}
?> ;