parsed_light mode to run site:instagram.com "your keyword" style queries, take the top 10 organic links from each response, classify them by platform and fire the matching social scraper asynchronously. At the end you’ll have one snapshot per platform, ready to be delivered to S3 or a webhook.
We stop at the trigger step. Routing the snapshots into storage is a delivery-config change that the other two tutorials in this series already cover.
What you’ll build
A single Python script that:- Runs three SERP API queries, one per platform, for your keyword
- Reads the top 10 organic results from each
parsed_lightresponse - Classifies each link as an Instagram post, a TikTok video or an X post
- Triggers the matching Bright Data social scraper for each platform’s URL list
- Prints one snapshot ID per platform
Prerequisites
- A Bright Data account with an API key (get your key)
- A SERP API zone created in the control panel. Follow the SERP API introduction once, then come back with the zone name
- Python 3.9+ installed locally
Part 1: Set up the project
Create a new folder and drop in arequirements.txt:
requirements.txt
Part 2: Discover mentions with the SERP API
The SERP API is a single REST endpoint:POST https://api.brightdata.com/request. You hand it a zone name and a Google Search URL, and it returns the SERP for that query. Pass data_format: "parsed_light" and you get back a compact JSON payload with just the top 10 organic results, no ads, no knowledge panels, no parsing to do on your side.
Create listen.py and start with the discovery step:
listen.py
data_format: "parsed_light"is the key. It tells the SERP API to return only the top 10 organic results in a compactorganicarray, skipping ads and knowledge panels. Faster response, less data to classify.format: "raw"is required alongsidedata_format. It refers to the outer HTTP response envelope, not the parsed payload. The SERP API docs spell this out.timeout=180is generous on purpose. Most SERP API calls return in well under a second, but a single query can occasionally take longer during Google rate-limiting. Three seconds of budget each keeps the script robust without being wasteful.
Part 3: Classify the URLs by platform
Each SERP response gives you anorganic array, and each entry has a link field pointing to a real post URL. You need to bucket those links so each scraper gets only the URLs it understands.
Add these helpers to listen.py:
listen.py
https:// URLs, not profile pages or topic pages. A profile URL like instagram.com/tiktok is rejected because this tutorial’s scrapers only take post URLs as input. The https:// prefix is strict on purpose: the social scrapers reject plain http:// URLs at validation time, so dropping them here avoids a 400 validation_error from the trigger step later. The dict.fromkeys trick de-duplicates while preserving order.
Part 4: Trigger the social scrapers
You now have three lists of post URLs. Fire them at the matching social scrapers with async triggers so each scraper can run on its own schedule without blocking the script:listen.py
- Discovery is synchronous, scraping is async. The SERP API returns in under a second per query, so you loop over three queries inline. The social scrapers can take several minutes each, so you trigger and exit. Bright Data runs them in the background.
- The script returns snapshot IDs, not data. The actual posts land wherever your scraper’s delivery config points (API download, webhook, or S3/GCS/Azure). See the two companion tutorials for webhook delivery and S3 delivery.
Part 5: Wire it together and run
Add amain block that glues the three steps:
listen.py
Congratulations
You’ve built a keyword social listener that:- Uses the SERP API in
parsed_lightmode as a compact, sub-second discovery engine - Takes the top 10 organic results per query and classifies them by platform with post-shape regexes
- Triggers the Instagram, TikTok and X scrapers in parallel on the discovered URLs
- Exits immediately after trigger, leaving the heavy work to Bright Data
Next steps
Deliver to a webhook
Point each social scraper at a webhook handler (like the Next.js one in the LinkedIn tutorial) to get mapped post records back in real time.
Deliver to S3
Configure S3 delivery on each scraper and schedule this script with GitHub Actions for a daily mention report.
Narrow the search
Full list of Google-specific query parameters you can add to the search URL, including
gl, hl, uule and time filters.SERP API reference
All supported engines, parsed output schema and async request mode for large volumes.