Tutorial

How to Extract Google Ads Data from SERP APIs

Pull Google Ads/sponsored results from SERP APIs. Extract ad copy, position, sitelinks, and shopping ads. Python walkthrough.

An r/ComplexWebScraping user asked about SERP APIs that return sponsored results. Google Ads data from SERP gives you competitor ad copy, position, and extensions without Google Ads API access. This tutorial shows how.

Prerequisites

  • Scavio API key
  • Python 3.8+

Walkthrough

Step 1: Fetch SERP with ads included

Standard Scavio Google search includes ads by default.

Python
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

def get_serp_with_ads(keyword):
    return requests.post('https://api.scavio.dev/api/v1/search',
        headers=H,
        json={'platform': 'google', 'query': keyword}).json()

Step 2: Extract sponsored results

Parse the ads_results or sponsored_results field.

Python
def extract_ads(serp):
    ads = serp.get('ads_results', []) or serp.get('sponsored_results', [])
    return [{'title': ad.get('title'), 'link': ad.get('link'),
             'description': ad.get('description'), 'position': i+1}
            for i, ad in enumerate(ads)]

Step 3: Extract shopping ads

Google Shopping results appear separately.

Python
def extract_shopping(serp):
    return [{'title': s.get('title'), 'price': s.get('price'),
             'source': s.get('source'), 'link': s.get('link')}
            for s in serp.get('shopping_results', [])]

Step 4: Track ad changes over time

Store daily snapshots for competitor ad monitoring.

Python
import json, datetime
def save_snapshot(keyword, ads, shopping):
    snapshot = {'date': str(datetime.date.today()), 'keyword': keyword,
                'ads': ads, 'shopping': shopping}
    with open(f'ad_snapshots/{keyword}.jsonl', 'a') as f:
        f.write(json.dumps(snapshot) + '\n')

Python Example

Python
# Monitor 50 keywords for competitor ads:
# 50 queries/day × $0.005 = $0.25/day = $7.50/mo
# Returns: ad copy, position, sitelinks, shopping ads

JavaScript Example

JavaScript
const serp = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST', headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
  body: JSON.stringify({platform: 'google', query: keyword})
}).then(r => r.json());

Expected Output

JSON
Daily snapshots of competitor Google Ads: ad copy, position, sitelinks, shopping ads. JSONL storage for trend analysis.

Related Tutorials

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.

Scavio API key. Python 3.8+. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 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.

Start Building

Pull Google Ads/sponsored results from SERP APIs. Extract ad copy, position, sitelinks, and shopping ads. Python walkthrough.