OSINT 4 min read

Automate Google Dorking for OSINT with Python

Build a scoped Python search review for authorized domains. Parse organic results, record observations, and separate search hits from verified exposure.

(Updated: ) • 775 words

Automated Google dorking is useful for reviewing how an authorized domain appears in search. A search hit is an observation, not proof of a vulnerability. Keep the query, URL, observation time and owner review together so the same check can be repeated without treating an empty result as an all-clear.

Define the review scope before the query

Start with domains your team owns or has explicit permission to review. This example searches for public documentation on one exact hostname. It does not enumerate credential patterns, probe endpoints or download sensitive findings. Subdomains need their own entries in the authorization list. A wildcard in a query is not an authorization policy.

Google documents the site: search operator and its limitations. Results are constrained by Google’s index and serving behavior; the operator is not a complete inventory. Compare the observations with your own published inventory before deciding that a page is absent.

Keep findings reviewable

Field Purpose
query Repeat the same search input
source_url Review the actual result rather than an inferred destination
observed_at Separate observation time from a page’s publication date
review_state Keep unreviewed findings out of confirmed-incident reports

Do not let an LLM convert every search snippet into a security finding. An owner should check whether the page is intentionally public, whether the indexed text still exists, and whether the underlying access policy is correct. Keep incident handling in your existing security process; a search API does not establish legal permission or a compliance status.

A Python adapter that validates the result contract

Install requests and set SEARCHCANS_API_KEY in the execution environment. Call exposure_review(domain, {domain}) only after that domain is approved. SearchCans Google Search API uses POST /api/v1/search. Its data value is an object, organic is the result array, and each accepted URL comes from link. HTTP and business errors raise separately from an empty array.

import os
import requests
from datetime import datetime, timezone
from urllib.parse import urlsplit, urldefrag

def organic(envelope):
    if envelope.get("code") != 0:
        raise ValueError("Search business error")
    data = envelope.get("data")
    if not isinstance(data, dict) or not isinstance(data.get("organic"), list):
        raise ValueError("Expected data.organic array")
    return [row for row in data["organic"] if isinstance(row, dict)
            and isinstance(row.get("link"), str)
            and urlsplit(row["link"]).scheme == "https"
            and urlsplit(row["link"]).hostname
            and not urlsplit(row["link"]).username]

def call(path, payload, session=requests, timeout=40):
    response = session.post("https://www.searchcans.com/api/v1/" + path,
        headers={"Authorization": "Bearer " + os.environ["SEARCHCANS_API_KEY"]},
        json=payload, timeout=timeout)
    response.raise_for_status()
    envelope = response.json()
    if envelope.get("code") != 0 or not isinstance(envelope.get("data"), dict):
        raise ValueError("Business or response-schema error")
    return envelope

def exposure_review(domain, authorized_domains, session=requests):
    if domain not in authorized_domains or not domain.replace(".", "").replace("-", "").isalnum():
        raise ValueError("Domain outside the explicit authorization scope")
    query = "site:" + domain + " public documentation"
    envelope = call("search", {"t":"google", "s":query,
        "country":"us", "language":"en", "d":30000}, session)
    records = []
    observed = datetime.now(timezone.utc).isoformat()
    for row in organic(envelope):
        if urlsplit(row["link"]).hostname != domain:
            continue
        records.append({"query":query, "source_url":row["link"],
            "observed_at":observed, "review_state":"needs_owner_review"})
    return records

Test the review policy without querying real exposures

Use a synthetic envelope containing one approved URL, one unrelated host and a row without link. Only the approved URL should become a needs_owner_review record. An empty organic array should return an empty observation set; a nonzero business code should raise. These fixture outcomes test parsing and scope enforcement, not Google coverage or security effectiveness.

For monitoring, retain only the information your review needs and set your own retention policy. Avoid copying confidential body text into a general-purpose research log. This guide makes no claim that API payloads are automatically discarded or that using an API makes a workflow compliant.

Use the controlled search-query workflow when you need to compare repeat runs, and the agent grounding architecture when a larger system must decide which observations can support an answer. That broader architecture does not replace owner review of an exposure.

Sources and verification

Tags:

OSINT Google Dorking Cybersecurity Python AI SERP API Automation
SearchCans Team

SearchCans Team

SERP API & Reader API Experts

The SearchCans engineering team builds high-performance search APIs serving developers worldwide. We share practical tutorials, best practices, and insights on SERP data, web scraping, RAG pipelines, and AI integration.

Ready to build with SearchCans?

Test SERP API and Reader API with 100 free credits. No credit card required.