惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
Cisco Talos Blog
Cisco Talos Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
美团技术团队
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
Engineering at Meta
Engineering at Meta
人人都是产品经理
人人都是产品经理
月光博客
月光博客
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recorded Future
Recorded Future
I
Intezer
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
罗磊的独立博客
V
V2EX
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
A
About on SuperTechFans
Scott Helme
Scott Helme
Vercel News
Vercel News
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Recent Announcements
Recent Announcements
Hacker News: Ask HN
Hacker News: Ask HN
C
CERT Recently Published Vulnerability Notes
G
Google Developers Blog
B
Blog
博客园 - 叶小钗
WordPress大学
WordPress大学
博客园 - 聂微东
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
IT之家
IT之家
C
Cybersecurity and Infrastructure Security Agency CISA
P
Palo Alto Networks Blog
小众软件
小众软件
博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
AWS News Blog
AWS News Blog

SerpApi

The State of the SERP in the Age of AI How to find the Google Knowledge Graph ID (kgmid) for anything What is an API? Part 2: Feeding the Machine (JSON) Building an Accessibility Search Experience with Google Flights, Hotels, and Maps APIs SerpApi Weekly Changelog: July 06-12, 2026 How to Scrape Google Flights Deals with a simple API Monitoring FIFA World Cup scores with a simple API How to scrape Google sports results Build Smarter Pydantic AI Agents with Real-Time Search A complete guide to web scraping with Ruby (2026) SerpApi Weekly Changelog: June 29- July 05, 2026 Make no mistakes: agent usability testing Semantic Image Search with Elasticsearch What is an API? Part 1: The Secret Life of a Web Browser MCP Apps with FastMCP: Turning Tool Output Into Interactive UI How to Scrape Naver AI Briefings with SerpApi Connect Sakana AI (Fugu) with Web Search API SerpApi Weekly Changelog: June 22-28, 2026 Trending Travel Destinations using Python & SerpApi How to scrape Bing reverse image search results Measuring Brand Presence Across AI Answer Engines SerpApi Weekly Changelog: June 15-21, 2026 How I Built a Star Wars Grogu Product Research Agent with Codex, Lark, and SerpApi How to scrape Bing web search results Categorizing hotels using Google Hotels images How to scrape Bing Images search results How to scrape Bing Copilot answers Build A No Code AI-Powered Local Lead Outreach System SerpApi Weekly Changelog: June 08-14, 2026 How to Do SEO Research with Claude Desktop and SerpApi MCP How to Extract Full Opinion Text from Google Scholar Case Law with SerpApi How to scrape Bing Maps search results SerpApi Weekly Changelog: June 01-07, 2026 Amazon ASIN Lookup API: Find and Fetch Product Details The State of MCP: Everything That Changed in H1 2026 How to scrape Bing News search results How to Connect Your Local LLM with Web Search Data SerpApi on Postman: One Unified Collection for Faster API Exploration SerpApi Weekly Changelog: May 25-31, 2026 Building an AI Agent in Python How to scrape Google Case Law API for Legal Research, Analytics, AI, and more SerpApi Achieves SOC 2 Type 2 and ISO 27001 Certification How to find your next product idea with Google Trends and SerpApi Scrape Competitors' Google Ads Data (Tutorial 2026) Using SerpApi and DeepSeek to Break Down Dan Koe’s Content Strategy SerpApi Weekly Changelog: May 18-24, 2026 How to scrape Bing Videos search results How to Scrape Instagram Profile Data with SerpApi How to scrape Bing Shopping search results How to Scrape Google Hotels Reviews SerpApi Weekly Changelog: May 11-17, 2026 5 Things You Can Build with Claude Code and Live Search Data Real Estate Data API for PropTech Developers How to Scrape Apple Maps with SerpApi How to scrape Google Trends
Track and Compare Product Prices Across Stores and Locations (SerpApi & Python)
Autumrose Stubbs · 2026-06-12 · via SerpApi

In modern e-commerce, pricing changes constantly across retailers and depends where you are located. This makes it difficult to track product value in real time. In this blog we'll review how to build a multi-store price tracking system across the globe, using SerpApi and Python.

Pull structured search data from Amazon, Walmart, Target, CVS, and more. Using this data you can monitor product prices, compare competitors, and maintain a continuously updated view of the market.

Getting Started with SerpApi

If you are new to SerpApi get started with this blog post:

Getting started with SerpApi: The Web Search API

Learn what SerpApi is, how to use it, and why you need it.

SerpApiHilman Ramadhan

Now that you are setup with SerpApi and have located your API key, let's take a look at SerpApi's libraries.

Libraries

In this example we will be using SerpApi's Python library.

To install the serpapi package, simply run the following command:

$ pip install serpapi

You can also make a simple GET request or for other programming languages, view our supported libraries here: https://serpapi.com/integrations.

Using SerpApi you can automatically gather product data across multiple stores and normalize it into a structured format. The goal is to build a tool that can:

  • Track a product across multiple retailers (e.g., Amazon, Walmart, Target, etc.)
  • Track a product across multiple locations
  • Support use cases like alerts, dashboards, or competitive analysis

SerpApi offers many different shopping APIs. For this example we will be using:

Amazon

  • Amazon Search API
    • Collect search results for a specific keyword.
    • Each result has the asin value for a specific product.
    • If you already have product asin values, skip this step.
  • Amazon Product API
    • Scrape full product page for a specific product using the asin value.

Walmart

  • Walmart Search API
    • Collect search results for a specific keyword.
    • Each result has the product_id value for a specific product.
    • If you already have product product_id values, skip this step.
  • Walmart Product API
    • Scrape full product page for a specific product using the product_id value.

Google Shopping (Additional Retailers)

  • Google Shopping API
    • Collect search results for a specific keyword.
    • Each result has the immersive_product_page_token value for a specific product.
    • If you already have product immersive_product_page_token values, skip this step.
  • Google Immersive Product API
    • There we can get the prices for many different stores.

Additional Shopping APIs

While SerpApi offers many additional APIs, this tutorial will focus on the three mentioned above.

For a complete list of available APIs, see the full documentation here:

Search engine APIs

Explore all of our search engine APIs for real-time search data

SerpApi

Price Comparison Steps

In this example we already have a product selected, including the Amazon asin, Walmart product_id, and name. As well as the location details needed to track different areas.

1. Set Target Stores

We start by specifying a list of stores we want to monitor. This allows us to control coverage and easily expand or reduce retailer tracking. In this case we are tracking:

target_stores = ["amazon","walmart", "target", "walgreens", "cvs"]

If you have additional target stores, you can easily add them to this list to track them as well.

2. Load Input Data

Read in a CSV file (products_input.csv) containing the Amazon asin, Walmart product_id, name, and location details.

My CSV:

name,asin,walmart_id,walmart_store,zip_code,state,country,country_code
M&M's Minis Milk Chocolate Candy Sharing,B09RBG3NWB,805902256,4554,78757,Texas,United States,US
M&M's Minis Milk Chocolate Candy Sharing,B09RBG3NWB,805902256,2568,91402,California,United States,US
M&M's Minis Milk Chocolate Candy Sharing,B09RBG3NWB,805902256,5293,11096,New York,United States,US
M&M's Minis Milk Chocolate Candy Sharing,B09RBG3NWB,805902256,5350,84117,Utah,United States,US

If you don't have your products' asin or walmart_id, you can collect these values using the Amazon Search API and the Walmart Search API.

Blogs to get started with either:

How to Scrape Walmart in 2026 (Complete guide)

Learn how to scrape Walmart product listings, extract product details, and collect customer reviews using SerpApi’s Walmart APIs. This step-by-step tutorial covers Python and JavaScript examples for retrieving structured Walmart data without maintaining scrapers.

SerpApiArtur Chukhrai

3. Initialize Structured Store Data

For each product, we create a standardized stores dictionary structure per store, initializing fields like:

  • price
  • search_id

There are many other data pieces returned in the results we can also include, however in this example we are just looking at the pricing.

4. Query SerpApi Per Product/Store Combination

We loop through each product and query SerpApi to retrieve search results for each location and all the stores available.

  • Amazon Product API - using the asin value as input
  • Walmart Product API - using the Walmart product_id
  • Google Shopping API - using the name
    • Google Immersive Product API - iterate through all the stores and collect the data for the relevant sellers.

5. Export or Extend the Output

Finally, the processed data can be:

  • Exported to CSV
  • Stored in a database
  • Used in dashboards
  • Extended into alerting/monitoring systems

In this example we'll export to a new CSV with the timestamp in the title.

Code

import serpapi 
import csv
from datetime import datetime

API_KEY = "YOUR_SECRET_API_KEY"

target_stores = ["amazon","walmart", "target", "walgreens", "cvs"]

# Query the Amazon Product API 
# Input parameters from the input CSV including asin, zip, and country
# Return Search ID and price
def amazon_search(asin, zip, country):
	search_id = ""
	price = ""

	# Query Amazon Product API using the asin value
	params = {
		"api_key": API_KEY,
		"engine": "amazon_product",
		"asin": asin,
		"delivery_zip": zip, 
		"shipping_location": country
	}

	results = serpapi.search(params).as_dict()

	# Check if required price fields are available
	if "product_results" in results:
		search_id = results["search_metadata"]["id"]
		amazon_product = results["product_results"] 
		if "price" in amazon_product:
			price = amazon_product["price"]
		else:
			price = "Unavailable"

	return search_id, price


# Query the Walmart Product API 
# Input parameters from the input CSV including the Walmart product ID and store ID
# Return Search ID and price
def walmart_search(walmart_id, store_id):
	search_id = ""
	price = ""
	# Query Walmart Product API using the product ID
	params = {
		"api_key": API_KEY,
		"engine": "walmart_product",
		"product_id": walmart_id,
		"store_id": store_id
	}

	walmart_results = serpapi.search(params).as_dict()

	# Check if required fields are available

	if "product_result" in walmart_results:
		search_id = walmart_results["search_metadata"]["id"]
		walmart_product = walmart_results["product_result"]
		if "price_map" in walmart_product:
			price = walmart_product["price_map"]["price"]
		else:
			price = "Unavailable"

	return search_id, price

# Query the Amazon Product API 
# Input parameters from the input CSV including asin, zip, and country
# Set applicable values in the global stores dictionary 
def google_shopping(product_name, location, country):
	addl_results = {}
	# Query the Google Shopping API using the product name extracted from the Walmart or Amazon Product APIs
	params = {
		"api_key": API_KEY,
		"engine": "google_shopping",
		"q": product_name,
		"location": location,
		"gl": country
	}

	shopping_results = serpapi.search(params).as_dict()

	# Verify there are shopping results available
	if "shopping_results" in shopping_results:
		google_shop_results = shopping_results["shopping_results"]

		if len(google_shop_results) > 0:

			# Set token to query the Google Immersive Product API from Google Shopping results
			immersive_product_token = shopping_results["shopping_results"][0]["immersive_product_page_token"]
			# Copy target stores to a set to track what we have found (already found Amazon and Walmart)
			remaining_stores = set(target_stores) - {"amazon", "walmart"}			
			# Token for next page of store results for a product
			next_page = ""

			# Iterate through Google Immersive Product results until there are no more stores in the results or target
			while True:
				params = {
					"api_key": API_KEY,
					"engine": "google_immersive_product",
					"page_token": immersive_product_token,
					"more_stores": "true",
					"next_page_token": next_page
				}
				immersive_results = serpapi.search(params).as_dict()

				# Check if there are product results within the results 
				if "product_results" in immersive_results:
					immersive_product = immersive_results["product_results"]

					# Check if there are stores within the product results
					if "stores" in immersive_product:
						stores_results = immersive_product["stores"]
						
						# Iterate through the stores available
						for store in stores_results:

							# Normalize and check if the store matches one of our target stores
							store_name = store["name"].lower().replace("'", "").replace(" ", "")
							match = next((s for s in remaining_stores if s in store_name), None)

							#If there's a match add the product details to our result dictionary
							if match:
								addl_results[match] = {
    								"price": store.get("price", "No Results"),
   									"search_id": immersive_results["search_metadata"]["id"]
								}
								# Remove match from the remaining target stores set
								remaining_stores.remove(match)

					# Assign next page token if it's available 
					if "stores_next_page_token" in immersive_product:
						next_page = immersive_product["stores_next_page_token"]
					# Otherwise break out of the loop (no more stores in results)
					else:
						break
				else:
					break
				# Break out of the loop if there are no more target stores remaining
				if not remaining_stores:
					break
	return addl_results	

# Write results out to a CSV file
def write_to_csv(rows, output_prefix="products_output"):
    flat_rows = []

    # Original input columns first
    input_columns = list(rows[0].keys())
    input_columns.remove("stores")

    # Store columns in desired order
    store_columns = []

    for store in target_stores:
        store_columns.extend([
            f"{store}_search_id",
            f"{store}_price"
        ])

    for row in rows:
        flat_row = {}

        # Add original CSV fields first
        for col in input_columns:
            flat_row[col] = row.get(col, "")

        # Add store fields in consistent order
        stores = row.get("stores", {})

        for store in target_stores:
            data = stores.get(store, {})

            flat_row[f"{store}_search_id"] = data.get("search_id", "")
            flat_row[f"{store}_price"] = data.get("price", "")

        flat_rows.append(flat_row)

    fieldnames = input_columns + store_columns

    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    output_file = f"{output_prefix}_{timestamp}.csv"

    with open(output_file, "w", newline="", encoding="utf-8") as outfile:
        writer = csv.DictWriter(outfile, fieldnames=fieldnames)
        writer.writeheader()
        writer.writerows(flat_rows)

def main():
	with open("products_input.csv", "r", newline="", encoding="utf-8") as infile:
		reader = csv.DictReader(infile)
		rows = list(reader)

		# Iterate through each row of the CSV
		for row in rows:
			stores = { 
				store: { "price": "No Results", "unit": "No Results", "search_id": "" } 
				for store in target_stores 
			}
			search_id, price = amazon_search(row["asin"], row["zip_code"], row["country"])
			stores["amazon"] = {"price": price, "search_id": search_id}

			search_id, price = walmart_search(row["walmart_id"], row["walmart_store"])
			stores["walmart"] = {"price": price, "search_id": search_id}

			stores.update(google_shopping(row['name'], f"{row['zip_code']},{row['state']},{row['country']}", row["country_code"]))
			row["stores"] = stores
	write_to_csv(rows)

if __name__ == "__main__":
	main()

Result Values

Within the results you will see 3 different pricing options, including:

An actual price

  • The product was found
  • The product has pricing details for the specified locaton
  • Ex: $3.58

"No Results"

  • The product was not found
  • The product doesn't have this seller listed in the location specified

"Unavailable"

  • The item was found however there was no pricing available
  • Ex: the product may not be available for sale in the selected location or sold out

For example in Amazon, this product was found however there is no pricing available for the specified location:

Now that we've identified the results structure, let's take a look at the results for this example.

Results

For visualization I have uploaded the returned CSV into Google Sheets with the input values highlighted gray and the price values highlighted yellow:

You can see the variance in pricing across stores and locations even for this 1 product across 4 different locations.

You can use this data to compare pricing across different locations, track competitor pricing, and much more!

Conclusion

Using SerpApi makes comparing product prices across different stores and locations effortless. While this example focused primarily on pricing data, the shopping / product APIs provide access to many other valuable data points, including product ratings, review counts, shipping details, availability, seller information, and more.

Additionally, the Google Immersive Product API supports a wide range of retailers outside of this target list, with available stores varying by country and region.

By combining data from multiple shopping sources and locations, organizations can build comprehensive price intelligence solutions, automate competitive analysis, and make more informed decisions based on real-time market data. Whether you're monitoring competitors, optimizing pricing strategies, conducting market research, or tracking product availability, SerpApi provides a flexible and scalable foundation for collecting and analyzing e-commerce data.

Resources