我必須修改一個公司的工具,爲SEO審計。如何獲得谷歌索引頁數
我的問題:我找不到谷歌索引頁數的解決方案。這是實際的代碼:
function get_indexed_page_count($url)
{
$ip = $_SERVER["SERVER_ADDR"];
$url = get_domain($url);
$result = json_decode(@file_get_contents("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:$url&filter=0&gl=fr&userip=$ip"));
return (int)$result->responseData->cursor->estimatedResultCount;
}
與此代碼:
$indexed_pages = get_indexed_page_count($url);
print_info("Nombre de pages indéxées dans Google.fr", get_status($indexed_pages, 1.1, 0.9, "Il y a " . $indexed_pages . " pages indéxées pour ce site sur Google.fr"));
然而,由於2016年,阿賈克斯googleapis被棄用,因此,我試圖修改這一行,但不管,我不能解決這個問題。
任何人都有一個想法來解決我的問題,並顯示有多少頁被索引(也許與「谷歌自定義搜索」?)?
謝謝。
此致,阿德里。
add'error_reporting(E_ALL); ini_set('display_errors',1);'在你的頁面頂部,並且擺脫@ in - > json_decode(@ - >你應該讓PHP給你一些有幫助的提示,因爲使用@就像試圖欺騙你的母親告訴她你清理了你的房間](https://z58i.imgup.net/Spring-Cledf29。gif)^^ – OldPadawan
這裏告訴我:注意:嘗試在119行上的/home/.../audit/optimisation.php中獲取非對象的屬性。該行對應於:return(int)$ result- > responseData-> CURSOR-> estimatedResultCount; –
有沒有辦法輕鬆獲取谷歌索引頁面? –