寫了一個小東西記錄baidu和google對于站點的收錄情況,現在可以查詢了,其實也沒什么難度,就是去file下遠程文件,然后分析下。
對了貌似查google pr的東西只是file一個地址而已,如此說了就沒有什么難度了
下面是代碼,對了getdetail函數也可以這樣寫,用正則去匹配
$wordf = preg_quote($wordf);
$wordb = preg_quote($wordb);
$pagecontent = @preg_replace("http://s*$wordf(.+?)$wordb/s*/e", "returndetail('//1', '$type')", $pagecontent);
$pagecontent = @preg_replace("http://s*".preg_quote($wordf)."(.+?)".preg_quote($wordb)."/s*/e", "returndetail('//1', '$type')", $pagecontent);
完整代碼如下,file取得文件,分析,輸出:
< ?php
$seodetail = array();
$domain = !empty($_GET['q']) ? $_GET['q'] : 'www.mycodes.net';
baidudetail($domain);
googledetail($domain);
var_dump($seodetail);
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', '相關網頁', '篇,用時');
getdetail($baidu_link, 'baidu_link', '相關網頁', '篇,用時');
getdetail($baidu_domain, 'baidu_domain', '相關網頁', '篇,用時');
}
function googledetail($domain) {
$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', '</b> 個結果,', ' 個。 (搜索用時');
getdetail($google_link, 'google_link', '<font size=-1>約有 <b>', '</b> 項鏈接到 <b>');//102
}
function getdetail($url, $type, $wordf, $wordb) {
$pagecontent = @file($url);
$pagecontent = implode('', $pagecontent);
$pagecontent = substr(strstr($pagecontent, $wordf), strlen($wordf));
$pagecontent = substr_replace($pagecontent, '', strpos($pagecontent, $wordb));
returndetail($pagecontent,$type);
}
function returndetail($content,$type) {
global $seodetail;
$seodetail[$type] = empty($content) ? 0 : $content;
}
?>