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.ini中的request_order推薦設(shè)置
這篇文章主要介紹了php.ini中的request_order推薦設(shè)置,需要的朋友可以參考下2015-05-05
高并發(fā)php uniqid不重復(fù)唯一標(biāo)識(shí)符生成方案
PHP 將圖片按創(chuàng)建時(shí)間進(jìn)行分類(lèi)存儲(chǔ)的實(shí)現(xiàn)代碼
PHP偽靜態(tài)Rewrite設(shè)置之APACHE篇
PHP數(shù)組去重的更快實(shí)現(xiàn)方式分析
PHP+SQL 注入攻擊的技術(shù)實(shí)現(xiàn)以及預(yù)防辦法
PHP實(shí)現(xiàn)求兩個(gè)字符串最長(zhǎng)公共子串的方法示例
PHP中return 和 exit 、break和contiue 區(qū)別與用法

