使用php怎么實現(xiàn)一個查詢百度和google收錄情況的功能?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
代碼如下:
$seodetail = array();
$domain = !empty($_GET['q']) ? $_GET['q'] : 'www.mycodes.net';
baidudetail($domain);
googledetail($domain);
var_dump($seodetail);
function baidudetail($domain) {
$baidu_site = '/tupian/20230522/baidu . $domain;
$baidu_link = '/tupian/20230522/baidu . $domain;
$baidu_domain = '/tupian/20230522/baidu . $domain;
getdetail($baidu_site, 'baidu_site', '相關網(wǎng)頁', '篇,用時');
getdetail($baidu_link, 'baidu_link', '相關網(wǎng)頁', '篇,用時');
getdetail($baidu_domain, 'baidu_domain', '相關網(wǎng)頁', '篇,用時');
}
function googledetail($domain) {
$google_site = '/tupian/20230522/search . $domain;
$google_link = '/tupian/20230522/search . $domain;
getdetail($google_site, 'google_site', ' 個結果,', ' 個。 (搜索用時');
getdetail($google_link, 'google_link', '約有 ', ' 項鏈接到 '); //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怎么實現(xiàn)一個查詢百度和google收錄情況的功能的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!