ScavioScavio
FeaturesPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Fetch Google Search Results in Python
Tutorial

How to Fetch Google Search Results in Python

Learn how to fetch live Google search results in Python using the Scavio API. No proxies, no scraping — structured JSON in under 10 lines of code.

Get Free API KeyAPI Docs

Fetching Google search results programmatically is a core requirement for SEO tools, research pipelines, and AI agents. The traditional approach — managing proxies, rotating user agents, and parsing raw HTML — is fragile and expensive. The Scavio API provides a single POST endpoint that returns structured JSON including organic results, featured snippets, knowledge graphs, and People Also Ask data. This tutorial walks through authenticating, forming a request, and parsing the response in Python using the requests library.

Prerequisites

  • Python 3.8 or higher installed
  • requests library installed (pip install requests)
  • A Scavio API key from scavio.dev
  • Basic familiarity with Python dictionaries and JSON

Walkthrough

Step 1: Install the requests library

If you do not already have requests installed, add it to your environment. It is the only dependency needed for this tutorial.

Bash
pip install requests

Step 2: Set your API key

Store your Scavio API key in an environment variable rather than hard-coding it. This keeps credentials out of source control.

Python
import os
API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")

Step 3: Send the search request

POST to the Scavio endpoint with your query and country code. The response is a JSON object containing organic results and SERP features.

Python
import requests

response = requests.post(
    "https://api.scavio.dev/api/v1/search",
    headers={"x-api-key": API_KEY},
    json={"query": "best python web frameworks", "country_code": "us"}
)
data = response.json()

Step 4: Parse and print organic results

The organic_results key contains a list of result objects. Each has title, link, and snippet fields.

Python
for result in data.get("organic_results", []):
    print(result["title"])
    print(result["link"])
    print(result.get("snippet", ""))
    print()

Python Example

Python
import os
import requests

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"

def search_google(query: str, country: str = "us") -> dict:
    response = requests.post(
        ENDPOINT,
        headers={"x-api-key": API_KEY, "Content-Type": "application/json"},
        json={"query": query, "country_code": country}
    )
    response.raise_for_status()
    return response.json()

def main():
    results = search_google("best python web frameworks")
    organic = results.get("organic_results", [])
    print(f"Found {len(organic)} results")
    for r in organic[:5]:
        print(f"- {r['title']}")
        print(f"  {r['link']}")

if __name__ == "__main__":
    main()

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";

async function searchGoogle(query, country = "us") {
  const response = await fetch(ENDPOINT, {
    method: "POST",
    headers: {
      "x-api-key": API_KEY,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ query, country_code: country })
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  return response.json();
}

async function main() {
  const results = await searchGoogle("best python web frameworks");
  const organic = results.organic_results || [];
  console.log(`Found ${organic.length} results`);
  organic.slice(0, 5).forEach(r => {
    console.log(`- ${r.title}`);
    console.log(`  ${r.link}`);
  });
}

main().catch(console.error);

Expected Output

JSON
{
  "search_metadata": { "query": "best python web frameworks", "country_code": "us" },
  "organic_results": [
    {
      "position": 1,
      "title": "Top Python Web Frameworks in 2026",
      "link": "https://example.com/python-frameworks",
      "snippet": "Django, FastAPI, and Flask remain the top choices..."
    },
    {
      "position": 2,
      "title": "FastAPI vs Django: Which Should You Use?",
      "link": "https://example.com/fastapi-vs-django",
      "snippet": "FastAPI is ideal for async microservices..."
    }
  ]
}

Related Tutorials

  • How to Track SEO Rankings Daily with the Scavio API
  • How to Extract People Also Ask Data from Google SERP

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8 or higher installed. requests library installed (pip install requests). A Scavio API key from scavio.dev. Basic familiarity with Python dictionaries and JSON. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best Search APIs After Google I/O 2026 AI Mode Changes

Read more
Best Of

Best Google Search API in 2026

Read more
Glossary

Search API Provider Landscape (2026)

Read more
Comparison

Brave Search API vs Scavio

Read more
Comparison

Google CSE (Paid Tier) vs Third-Party SERP API (Scavio, SerpApi, Serper)

Read more
Use Case

n8n Search Enrichment Workflow

Read more

Start Building

Learn how to fetch live Google search results in Python using the Scavio API. No proxies, no scraping — structured JSON in under 10 lines of code.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy