php實現(xiàn)查詢百度google收錄情況(示例代碼)
寫了一個小東西記錄baidu和google對于站點的收錄情況,現(xiàn)在可以查詢了,其實也沒什么難度,就是去file下遠程文件,然后分析下。
對了貌似查google pr的東西只是file一個地址而已,如此說了就沒有什么難度了。
完整代碼如下,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', '相關(guān)網(wǎng)頁', '篇,用時');
getdetail($baidu_link, 'baidu_link', '相關(guān)網(wǎng)頁', '篇,用時');
getdetail($baidu_domain, 'baidu_domain', '相關(guān)網(wǎng)頁', '篇,用時');
}
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> 個結(jié)果,', ' 個。 (搜索用時');
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;
}
?>
- php使用curl檢測網(wǎng)頁是否被百度收錄的示例分享
- php中通過curl檢測頁面是否被百度收錄
- PHP簡單獲取網(wǎng)站百度搜索和搜狗搜索收錄量的方法
- php檢查頁面是否被百度收錄
- php獲取百度收錄、百度熱詞及百度快照的方法
- php實現(xiàn)檢查文章是否被百度收錄
- php檢測網(wǎng)頁是否被百度收錄的函數(shù)代碼
- PHP CURL CURLOPT參數(shù)說明(curl_setopt)
- 在PHP中使用curl_init函數(shù)的說明
- PHP中CURL的CURLOPT_POSTFIELDS參數(shù)使用細節(jié)
- php基于curl主動推送最新內(nèi)容給百度收錄的方法