How to Extract Google Shopping Prices using X-Byte Scraper

X-Byte Enterprise Crawling
2 min readAug 2, 2021

You can scrape data from Google Shopping using X-Byte Scraper. You can check the demo.

Initially, install a google-search-results package. You may use poetry to do package management.

[tool.poetry.dependencies] python = "^3.8" google-search-results = "^2.0.0" [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api"

After that, save the subsequent Python script, which scrapes and prints the Google Shopping pricing into a scrape_google_shopping.py file.

# https://pypi.org/project/google-search-results from X-Byte Scraper 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']}""")

After that, install dependencies as well as execute a script.

python3 -m poetry install python3 scrape_google_shopping.py

After that, you’ll get product titles as well as prices in CLI.

Raw HTML: https://X-Byte Scraper.com/searches/e8b8fa4e992f8961/5ec3fcad3c6d8e70e22b5f71.html JSON endpoint: https://X-Byte Scraper.com/searches/e8b8fa4e992f8961/5ec3fcad3c6d8e70e22b5f71.json Google Shopping prices Title: Dunkin' Donuts Original Blend Coffee K-Cups - 44 count, 16.3 oz box Price: $17.99 Extracted price: 17.99 Title: Lavazza Super Crema Espresso Whole Bean Coffee - 2.2 lb bag Price: $23.00 Extracted price: 23.0 Title: Nescafe Coffee, Instant, House Blend - 7 oz Price: $7.95 Extracted price: 7.95 Title: Black Rifle Coffee Company Freedom Fuel Coffee Price: $13.99 Extracted price: 13.99 Title: Coffee Tasting Starter Kit Price: $5.00 Extracted price: 5.0 Title: Folgers Classic Roast Coffee, Medium - 48 oz canister Price: $9.96 Extracted price: 9.96

You can check the X-Byte Scraper documentation for more details or contact us.

Originally published at https://www.xbyte.io.

--

--

X-Byte Enterprise Crawling

Offer web scraping & Data extraction services like Amazon data scraping, Real Estate,eBay, Travel & all type of services per client requirements. www.xbyte.io