BYTESLIP ← Back
Knowledge Base // Tutorial 126

Find Real Googlebot Visits in cPanel Raw Access Logs With Python

Difficulty: Medium ~30 min cPanel · Python · Logs

Search Console shows Google’s side of things. Your server’s access log shows every request that actually reached your site, including every visit from Googlebot. Plenty of other bots also call themselves Googlebot. This guide downloads cPanel’s raw access logs and runs a Python script that keeps only requests from Google’s published crawler IP ranges. It then shows how often Google crawls you, what it fetched, and every URL that sent it a 404 or a redirect.

Raw access log to a verified Googlebot report Four tiles: raw access log file, Googlebot user agent, Google IP ranges check, report. RAW ACCESS .GZ GOOGLEBOT UA? GOOGLE IP RANGES REPORT
Safety // Read First

Warnings

ImportantAccess logs contain visitors’ IP addresses. Keep the files private, don’t upload or share them, and delete your copies when you’re done. Google says the user-agent string can be spoofed, so never trust “Googlebot” in a log line on its own; that’s why the script checks the IP address.

Checklist // Before You Start

What You Need

How this was tested: Ran with Python 3.13 and 3.12 on a sample log built from Google’s own example crawler IP, plus one fake Googlebot from a documentation address range, in both plain and .gz form. Downloading Google’s IP list live and using a saved copy gave identical results, and an IPv6 address in Google’s list matched. Then we ran it on 68,466 lines of real cPanel raw access logs from a small static site (October–November 2026). It read every line. Of 1,457 requests that claimed to be Googlebot, 497 came from Google’s published ranges.

Walkthrough // Steps 01–06

Download → read a line → verify → run → act

One download a month is enough for a small site.

  1. Step 1: Download the raw access logs

    In cPanel, open Raw Access. Under Download Current Raw Access Logs, click your domain to download a .gz file. Previous months are under Archived Raw Logs, but only if archiving is on. Tick the box labeled “Archive log files in your home directory after the system processes statistics.” and click Save, so next month you have history to compare.

    On the cPanel host we tested, HTTPS requests were in a file named like example.com-ssl_log-Nov-2026.gz and plain HTTP in example.com-Nov-2026.gz. Download both; the script reads several files at once.

  2. Step 2: Learn to read one log line

    66.249.66.1 - - [16/Nov/2026:03:12:04 -0500] "GET /tutorials/ HTTP/1.1" 200 9120 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.122 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

    From left to right: the visitor’s IP, the time (with the server’s time zone offset), the request line, the status code (200), the response size in bytes, the referrer (- for none) and the user agent. This is Apache’s combined log format. Googlebot Smartphone’s user agent includes Mobile; Googlebot Desktop’s doesn’t.

  3. Step 3: Know how Google says to verify Googlebot

    Google gives two methods. For one-off checks, run a reverse DNS lookup on the IP, check that the name ends in googlebot.com, google.com or googleusercontent.com, then look that name up and confirm it returns the same IP. Google’s example:

    host 66.249.66.1
    1.66.249.66.in-addr.arpa domain name pointer crawl-66-249-66-1.googlebot.com.
    
    host crawl-66-249-66-1.googlebot.com
    crawl-66-249-66-1.googlebot.com has address 66.249.66.1

    For whole log files, the faster method is to match each IP against Google’s IP range list for common crawlers like Googlebot, common-crawlers.json. That’s what the script does.

  4. Step 4: Save the script

    Save this as gbot_logs.py. It uses only Python’s standard library:

    #!/usr/bin/env python3
    """Summarize Googlebot hits in cPanel raw access logs (Apache combined format).
    
    Usage: python3 gbot_logs.py [--ranges common-crawlers.json] LOG [LOG ...]
    LOG can be plain text or .gz, exactly as cPanel's Raw Access page gives it.
    """
    import collections, gzip, ipaddress, json, re, sys, urllib.request
    
    RANGES_URL = "https://developers.google.com/static/crawling/ipranges/common-crawlers.json"
    LINE = re.compile(r'^(\S+) \S+ \S+ \[(\d+/\w+/\d+):[^\]]*\] "(?:(\S+) (\S+)[^"]*|[^"]*)" '
                      r'(\d{3}) (\S+) "[^"]*" "([^"]*)"')
    
    def load_ranges(path=None):
        if path:
            data = json.load(open(path, encoding="utf-8"))
        else:
            with urllib.request.urlopen(RANGES_URL, timeout=30) as r:
                data = json.load(r)
        return [ipaddress.ip_network(p.get("ipv4Prefix") or p["ipv6Prefix"]) for p in data["prefixes"]]
    
    def open_log(path):
        if path.endswith(".gz"):
            return gzip.open(path, "rt", encoding="utf-8", errors="replace")
        return open(path, encoding="utf-8", errors="replace")
    
    def main(argv):
        ranges_file = None
        if argv[:1] == ["--ranges"]:
            ranges_file, argv = argv[1], argv[2:]
        if not argv:
            sys.exit(__doc__)
        nets = load_ranges(ranges_file)
        cache = {}
        def from_google(ip):
            if ip not in cache:
                try:
                    addr = ipaddress.ip_address(ip)
                    cache[ip] = any(addr.version == n.version and addr in n for n in nets)
                except ValueError:
                    cache[ip] = False
            return cache[ip]
    
        lines = unparsed = claimed = 0
        fake = collections.Counter()
        days, status, kind, paths = (collections.Counter() for _ in range(4))
        problems = collections.defaultdict(collections.Counter)
        for path in argv:
            with open_log(path) as f:
                for line in f:
                    lines += 1
                    m = LINE.match(line)
                    if not m:
                        unparsed += 1
                        continue
                    ip, day, method, url, code, size, ua = m.groups()
                    if "Googlebot" not in ua:
                        continue
                    claimed += 1
                    if not from_google(ip):
                        fake[ip] += 1
                        continue
                    days[day] += 1
                    status[code] += 1
                    kind["smartphone" if "Mobile" in ua else "desktop/other"] += 1
                    paths[url or "-"] += 1
                    if code[0] in "345" and code != "304":
                        problems[code][url or "-"] += 1
    
        real = claimed - sum(fake.values())
        print(f"Lines read: {lines}   unparsed: {unparsed}")
        print(f"Claimed Googlebot: {claimed}   verified by IP: {real}   fake: {sum(fake.values())} from {len(fake)} IPs")
        print("\nVerified hits per day:")
        for day, n in days.items():
            print(f"  {day}  {n}")
        print("\nStatus codes:", dict(status.most_common()))
        print("Crawler type:", dict(kind.most_common()))
        print("\nMost crawled URLs:")
        for url, n in paths.most_common(15):
            print(f"  {n:5}  {url}")
        for code in sorted(problems):
            print(f"\nGooglebot got {code} on:")
            for url, n in problems[code].most_common(20):
                print(f"  {n:5}  {url}")
        if fake:
            print("\nTop fake 'Googlebot' IPs (not in Google's list):")
            for ip, n in fake.most_common(10):
                print(f"  {n:5}  {ip}")
    
    if __name__ == "__main__":
        main(sys.argv[1:])
  5. Step 5: Run it

    python3 ~/gbot_logs.py ~/storage/downloads/example.com-ssl_log-Nov-2026.gz ~/storage/downloads/example.com-Nov-2026.gz

    To work offline or with a fixed copy, download the list once and pass it in:

    curl -sO https://developers.google.com/static/crawling/ipranges/common-crawlers.json
    python3 ~/gbot_logs.py --ranges common-crawlers.json ~/storage/downloads/*.gz

    Output from the sample log:

    Lines read: 7   unparsed: 0
    Claimed Googlebot: 6   verified by IP: 5   fake: 1 from 1 IPs
    
    Verified hits per day:
      16/Nov/2026  3
      17/Nov/2026  2
    
    Status codes: {'200': 2, '404': 1, '301': 1, '304': 1}
    Crawler type: {'desktop/other': 3, 'smartphone': 2}
    
    Most crawled URLs:
          2  /tutorials/
          1  /robots.txt
          1  /tutorials/old-guide/
          1  /tutorials/index.html
    
    Googlebot got 301 on:
          1  /tutorials/index.html
    
    Googlebot got 404 on:
          1  /tutorials/old-guide/
    
    Top fake 'Googlebot' IPs (not in Google's list):
          1  203.0.113.9
  6. Step 6: Act on what you find

    • 404 / 410: if a removed page has a clear replacement, add a 301; otherwise a 404 is fine. See Custom 404 Pages and Soft 404 Fixes.
    • 301: Google is still requesting an old or non-canonical address. Update internal links and your sitemap to point at the final URL (Clean URLs). A 301 on /robots.txt in the HTTP log is normal when the site forces HTTPS.
    • 5xx or 429: Google treats both as server errors and slows down its crawling. Ask your host about resource limits or firewall rules.
    • A page you just published isn’t in the list: Google hasn’t crawled it yet. Link to it from related pages and see Get New Pages Crawled.
    • Fake Googlebots: they aren’t Google, so they say nothing about your Search crawling. Leave them out of your stats.
Pro Tip

Spot a bot check in the sizes

Questions // FAQ

FAQ

Why isn’t URL Inspection in the report?

URL Inspection and the Rich Results Test fetch as Google-InspectionTool. Its user agent doesn’t include “Googlebot”, so the script skips it.

Why are times off from my clock?

Each timestamp ends with the server’s time zone offset, for example -0500. Convert from that offset to your own time zone.

Is it safe to block the fake Googlebots?

Google says to verify a request before you block anything that claims to be Googlebot. An IP that isn’t in Google’s lists and fails the DNS check isn’t Google. Blocking it is up to you and your host.

Does this work for other search engines?

Not as written. The script only looks for Googlebot and checks Google’s IP list, so other search engines’ crawlers are ignored.

Keep Reading
Sources // Verified

Official docs

Verification methods, the host example and the IP range lists: Verify requests from Google crawlers. User-agent strings, spoofing and Google-InspectionTool: Google’s common crawlers. 429 and 5xx handling: How HTTP status codes affect Google’s crawlers. Downloading and archiving logs: cPanel Raw Access. Log format: Apache log files. Script modules: ipaddress and gzip.

← All Tutorials Byteslip Apps