Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import os
from serpapi import GoogleSearch
# Search query parameters
params = {
"engine": "google",
"q": "cpu buy",
"api_key": os.getenv("API_KEY"),
search = GoogleSearch(params)
results = search.get_dict()
# Iterating over 'results' variable and calling for 'shopping_results'
for ad in results['shopping_results']: # For regular ads -> ['ads']
shopping_ad = ad['link'] # for regular ads -> ad['tracking_link']
# Output for Shopping Ads
# Output for Regular Website Ads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment