T
T
TotTip2020-07-30 09:06:05
Google
TotTip, 2020-07-30 09:06:05

How to find the number of pages in the Google index?

Hello!
How to find the number of pages in the Google index?
maybe there is some API for this?
I tried to get the page https://www.google.com/search?hl=ru&q=site:site.ru via curl and parse it, but the number of pages is displayed only in the browser, when the page is received via curl, another page with results comes (without this data)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2020-07-30
@TotTip

I don't know, I checked everything works for me

<?PHP
$ch = curl_init();
$site = "https://habr.com/";
$url = "https://www.google.com/search?hl=ru&q=site:$site";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0');
$content = curl_exec($ch);
if(!$content){
    echo 'Ошибка curl: ' . curl_error($ch);
  die;
}

curl_close($ch);

if(preg_match("/Результатов:\s*(примерно)?\s*([^(]+)/",$content,$matches))
  echo "Количество: ".$matches[2];
else
  echo "Не найдено";
?>

PS Well, these are hardly all pages, if you are for your site, then use the Google search console

D
Dimonchik, 2020-07-30
@dimonchik2013

No API, parse with selenium
autoparsing Google requires knowledge

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question