Last active
January 4, 2021 15:49
-
-
Save ilyazub/b2f7a2835ed3bd182a71b949ed29db5e to your computer and use it in GitHub Desktop.
Extract Google Shopping prices via SerpApi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://pypi.org/project/google-search-results | |
from serpapi import GoogleSearch | |
import os | |
params = { | |
"engine": "google", | |
"q": "Coffee", | |
"tbm": "shop", | |
"api_key": os.getenv("API_KEY") | |
} | |
client = GoogleSearch(params) | |
data = client.get_dict() | |
print(f"Raw HTML: {data['search_metadata']['raw_html_file']}") | |
print(f"JSON endpoint: {data['search_metadata']['json_endpoint']}") | |
print() | |
print("Google Shopping prices") | |
for result in data["shopping_results"]: | |
print(f""" | |
Title: {result['title']} | |
Price: {result['price']} | |
Extracted price: {result['extracted_price']}""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output