Check if URL is indexed by Google using PHP

前端 未结 4 1907
太阳男子
太阳男子 2021-01-18 18:24

I would like to know if it\'s possible to check if URL is indexed by Google using PHP.

Is this against their ToS?

4条回答
  •  迷失自我
    2021-01-18 19:01

    Well, not explicitly. But you can check every page view using:

    $agent = $_SERVER['HTTP_USER_AGENT'];
    
    if (strstr($agent, 'googlebot')){
    
      // tell the database that google has crawled this page.
    }
    

提交回复
热议问题