php實(shí)現(xiàn)查詢(xún)百度google收錄情況(示例代碼)
寫(xiě)了一個(gè)小東西記錄baidu和google對(duì)于站點(diǎn)的收錄情況,現(xiàn)在可以查詢(xún)了,其實(shí)也沒(méi)什么難度,就是去file下遠(yuǎn)程文件,然后分析下。
對(duì)了貌似查google pr的東西只是file一個(gè)地址而已,如此說(shuō)了就沒(méi)有什么難度了。
完整代碼如下,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)頁(yè)', '篇,用時(shí)');
getdetail($baidu_link, 'baidu_link', '相關(guān)網(wǎng)頁(yè)', '篇,用時(shí)');
getdetail($baidu_domain, 'baidu_domain', '相關(guān)網(wǎng)頁(yè)', '篇,用時(shí)');
}
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> 個(gè)結(jié)果,', ' 個(gè)。 (搜索用時(shí)');
getdetail($google_link, 'google_link', '<font size=-1>約有 <b>', '</b> 項(xiàng)鏈接到 <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檢測(cè)網(wǎng)頁(yè)是否被百度收錄的示例分享
- php中通過(guò)curl檢測(cè)頁(yè)面是否被百度收錄
- PHP簡(jiǎn)單獲取網(wǎng)站百度搜索和搜狗搜索收錄量的方法
- php檢查頁(yè)面是否被百度收錄
- php獲取百度收錄、百度熱詞及百度快照的方法
- php實(shí)現(xiàn)檢查文章是否被百度收錄
- php檢測(cè)網(wǎng)頁(yè)是否被百度收錄的函數(shù)代碼
- PHP CURL CURLOPT參數(shù)說(shuō)明(curl_setopt)
- 在PHP中使用curl_init函數(shù)的說(shuō)明
- PHP中CURL的CURLOPT_POSTFIELDS參數(shù)使用細(xì)節(jié)
- php基于curl主動(dòng)推送最新內(nèi)容給百度收錄的方法
相關(guān)文章
PHP文件打開(kāi)關(guān)閉及讀寫(xiě)操作示例解析
這篇文章主要介紹了PHP文件打開(kāi)關(guān)閉及讀寫(xiě)操作示例解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08PHP封裝的分頁(yè)類(lèi)與簡(jiǎn)單用法示例
這篇文章主要介紹了PHP封裝的分頁(yè)類(lèi)與簡(jiǎn)單用法,結(jié)合實(shí)例形式分析了php數(shù)據(jù)庫(kù)查詢(xún)、分頁(yè)、輸出顯示等相關(guān)操作技巧,需要的朋友可以參考下2019-02-02