How to Extract Walmart Data

Businesses today need more than just insights, they need transformative, real-time data solutions to stay ahead in a rapidly evolving market. As one of the largest retailers globally, Walmart offers a wealth of data that can help businesses monitor pricing trends, analyze product performance, and optimize inventory management. However, effective ecommerce data scraping at Walmart’s scale comes with its challenges. This guide walks through a working Python script that scrapes Walmart product data from the page’s embedded JSON, then covers where that script stops being enough.
Related: Ecommerce Data Scraping
Quick Digest
- Uses: Walmart data supports price monitoring, inventory insights and market trend analysis.
- DIY route: A short Python script can find product URLs in Walmart’s sitemaps, read name, price and rating from the page’s embedded JSON and save them to CSV.
- Hard parts: JavaScript-heavy pages, frequent layout updates and rate limits lead to inconsistent results or IP bans.
- Managed option: Automated pipelines that adapt to site changes remove ongoing scraper maintenance.
What can Walmart data do for your business?
Walmart data provides businesses with critical insights that support strategic decision-making. Here are some real-world applications:
- Price Monitoring: Keep track of competitor/ category pricing trends to refine your pricing strategy. Teams building a broader price intelligence program pair Walmart feeds with competitor price tracking workflows to benchmark across marketplaces and react to shifts faster.
- Inventory Insights: Analyze stock levels to improve supply chain efficiency.
- Market Trends: Identify seasonal patterns and customer preferences.
- Sales Analytics: Measure performance across product categories to highlight high-demand resources.
- Product Development: Evaluate customer feedback/ reviews for new product launches.
- Competitor Benchmarking: Gain a competitive edge by understanding marketplace dynamics.
Expert Insights
The scale behind that data is large. The About Walmart page on the company's corporate site states: "Each week, approximately 280 million customers and members visit our more than 10,900 stores and numerous eCommerce websites in 19 countries." (Walmart, 2026). Pricing, stock and assortment signals from a retailer with that reach are useful benchmarks for most consumer categories.
How to scrape Walmart data with Python
Most Walmart scraping tutorials still point a browser at the page and hunt for CSS class names. Those class names are generated by the build, so they change whenever Walmart ships a release, and your script breaks quietly. There is a steadier source sitting in the same page.
Walmart’s storefront is a Next.js app. Each product page carries its data as JSON inside a <script id="__NEXT_DATA__"> tag, so you can read name, price and rating without a browser and without guessing at selectors. The walkthrough below uses that tag, finds product URLs through the sitemaps Walmart publishes, and stops the moment Walmart says no.
You need Python 3.9 or later and two libraries:
pip install requests beautifulsoup4

Step 1: Set up a polite session
Start with one session that identifies your script, reads Walmart’s robots.txt once, and waits between requests. The fetch helper refuses any URL robots.txt disallows and raises an error when Walmart redirects to its block page, instead of retrying around it.
import csv
import gzip
import json
import time
import xml.etree.ElementTree as ET
from urllib import robotparser
import requests
from bs4 import BeautifulSoup
BASE = "https://www.walmart.com"
DELAY_SECONDS = 5 # one request every 5 seconds, per client
session = requests.Session()
session.headers.update({
# Say who you are. Replace with your own project name and contact.
"User-Agent": "price-research-script/0.1 (contact: you@yourcompany.com)",
"Accept-Language": "en-US,en;q=0.9",
})
robots = robotparser.RobotFileParser(BASE + "/robots.txt")
robots.read()
def fetch(url, params=None):
"""Fetch one page politely. Stop on a block page instead of retrying around it."""
if not robots.can_fetch("*", url):
raise PermissionError(f"robots.txt disallows {url}")
time.sleep(DELAY_SECONDS)
resp = session.get(url, params=params, timeout=30)
if resp.status_code != 200 or "/blocked" in resp.url:
raise RuntimeError(f"Blocked or failed ({resp.status_code}): {resp.url}")
return resp
Step 2: Find product URLs in Walmart’s sitemaps
Walmart lists more than 30 sitemaps in its robots.txt, including category and product files. Discovering URLs there is cheaper than crawling, and it keeps you off the search pages. Some sitemaps are indexes that point to gzipped child files, so the function below handles both.
SM_NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}
def sitemap_locs(sitemap_url):
"""Return every <loc> in a sitemap or sitemap index, handling .gz files."""
raw = fetch(sitemap_url).content
if raw[:2] == b"\x1f\x8b": # gzip magic bytes
raw = gzip.decompress(raw)
root = ET.fromstring(raw)
return root.tag.endswith("sitemapindex"), [
loc.text.strip() for loc in root.findall(".//sm:loc", SM_NS)
]
def product_urls(sitemap_url, limit=50):
"""Walk a sitemap (or the first child of an index) and keep product URLs."""
is_index, locs = sitemap_locs(sitemap_url)
if is_index:
is_index, locs = sitemap_locs(locs[0])
return [u for u in locs if "/ip/" in u][:limit]
Step 3: Parse the product page’s embedded JSON
This is the core of the script. Load the __NEXT_DATA__ JSON, walk to the product object and pull the fields you need. Current tutorials agree on the path props → pageProps → initialData → data → product, with the display price at priceInfo.currentPrice.priceString. Treat the lines marked VERIFY as a prompt to open the JSON for one real page in your browser’s dev tools and confirm the key name before you run at any volume.
def next_data(html):
"""Return the parsed __NEXT_DATA__ JSON, or fail loudly."""
soup = BeautifulSoup(html, "html.parser")
tag = soup.find("script", id="__NEXT_DATA__")
if tag is None:
raise RuntimeError("No __NEXT_DATA__ tag: likely a challenge page")
return json.loads(tag.string)
def parse_product(url):
data = next_data(fetch(url).text)
product = data["props"]["pageProps"]["initialData"]["data"]["product"]
price = (product.get("priceInfo") or {}).get("currentPrice") or {}
return {
"url": url,
"name": product.get("name"),
"price": price.get("price"), # key names change: confirm in __NEXT_DATA__
"price_display": price.get("priceString"),
"rating": product.get("averageRating"),
"reviews": product.get("numberOfReviews"), # confirm key in __NEXT_DATA__
}
Key paths drift. When a field comes back empty, print json.dumps(product, indent=2) for one page and search it for the value you can see on screen.
Step 4: Page through category listings
Many guides paginate Walmart’s search results. We don’t: Walmart’s robots.txt disallows /search. Category pages under /browse/ are not disallowed, and the category sitemap gives you their URLs. Listing pages hold up to 40 items each, and the loop ends when a page comes back empty.
def browse_items(category_url, max_pages=5):
"""Yield product items from a category page, one page at a time."""
for page in range(1, max_pages + 1):
data = next_data(fetch(category_url, params={"page": page}).text)
result = data["props"]["pageProps"]["initialData"].get("searchResult") or {} # confirm on a browse page
items = [i for stack in result.get("itemStacks", []) for i in stack.get("items", [])]
if not items:
break # past the last page
yield from items
Step 5: Save to CSV and stop on blocks
The last step ties it together. It writes one row per product, skips rows where the JSON path returned nothing, and stops the whole run on the first block page. A block page often arrives as a normal-looking response, so check the data, not only the status code.
def run(sitemap_url, out_file="walmart_products.csv", limit=50):
fields = ["url", "name", "price", "price_display", "rating", "reviews"]
with open(out_file, "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=fields)
writer.writeheader()
for url in product_urls(sitemap_url, limit=limit):
try:
row = parse_product(url)
except RuntimeError as err:
print(f"Stopping: {err}")
break # a block page means slow down or stop, not retry harder
if row["name"] and row["price_display"]:
writer.writerow(row)
else:
print(f"Empty fields, check the JSON path: {url}")
if __name__ == "__main__":
print(robots.site_maps()) # every sitemap Walmart lists in robots.txt
# Pick the product sitemap from that list. File names change, so check the index.
run("https://www.walmart.com/sitemap_product_03.xml", limit=20)
Run it on 20 products first. In our own test on 16 October 2026, two plain requests from one IP were redirected to Walmart’s block page before any JSON came back. Expect the same, and treat the script as a way to sample and prototype, not as a production feed.
Use the script responsibly
This article is for informational purposes only and does not constitute legal advice. Consult a qualified attorney for legal guidance specific to your situation.
- robots.txt: the script checks it on every request. Following it is a floor, not a permission, and it does not settle whether a given collection is allowed.
- Rate: one request every few seconds from one client. Cache pages you have already fetched instead of fetching them again.
- Terms of use: read Walmart’s terms before you collect anything. A block page is Walmart telling you no; slow down or stop rather than rotating around it.
- Data: collect product fields only. Leave out reviewer names and anything else that identifies a person.
No law bans web scraping as such. Whether a particular collection is lawful turns on the data (personal, copyrighted or factual), the access (logged in, past a barrier, against a stated refusal) and the use (internal analysis versus republication or resale).
Why is Walmart data hard to extract?
Extracting data from Walmart’s dynamic ecosystem is far from simple. The website’s JavaScript-heavy content, frequent architectural updates, and rate-limiting mechanisms can complicate the process, leading to inconsistent results or IP bans. Additionally, managing the sheer volume of data requires dedicated infrastructure and people who know it. The embedded JSON is steadier than CSS classes, but its key paths still move, and block pages often arrive looking like normal responses, so a script can log a clean run while writing empty rows. These challenges often demand a more advanced approach for businesses requiring timely and large-scale data.
Expert Insights
The online side is also growing quickly. In its Q2 FY27 Earnings Release (August 2026), Walmart Inc. reported "eCommerce sales up 23% globally" and a "Global advertising business up 38%." A fast-growing catalog means more pages to cover and more changes for any extraction setup to keep up with.
Key challenges include:
- Managing the scalability of massive and diverse data sets
- Meeting custom requirements like regional filtering or real-time availability checks
- Maintaining consistent data quality without automated systems
- Addressing the resource-intensive need for ongoing maintenance due to frequent updates in Walmart’s architecture
- Ensuring robust infrastructure capable of handling large-scale operations with features like autoscaling and advanced error handling.
These challenges emphasize the importance of having a sophisticated, end-to-end data extraction infrastructure designed to handle the complexities of Walmart’s ecosystem with intelligence and precision.
A managed way to get Walmart data
After navigating Walmart’s complex data ecosystem, the question arises: how can businesses achieve efficient, scalable data extraction without facing bottlenecks? Manual scraping, limited data access, and the constant need for code adjustments slow every team that depends on the data. These challenges slow down your processes and leave missed business opportunities behind them. Forage AI is an end-to-end managed data pipeline: it automates discovery, extraction, structuring, quality checks and delivery, built to your own fields and systems.
Today’s web data extraction solutions leverage advanced intelligence to meet complex business needs, transforming raw data into actionable, high-quality insights for immediate application.
Advanced Methods for Web Data Extraction:
- Adaptive extraction: Using Large Language Models (LLMs), Retrieval-Augmented Generation (RAG), and Agentic AI, systems now adapt dynamically to evolving website architectures, ensuring uninterrupted data flow.
- Automation: Pipelines handle everything from discovery to delivery, so nobody on your team maintains selectors or key paths.
- Scale: Forage AI extracts from 500M+ websites, so Walmart sits alongside the other retailers you track.
- Quality checks: A 200% QA approach, automated checks plus human verification, on every delivery.

Forage AI handles selector drift, anti-bot evolution and schema changes as part of the service, and delivers Walmart data in your fields on your schedule. Learn more about our web data extraction services or talk to our experts to scope a Walmart data pipeline.
Get started with Forage AI and unlock the power of Walmart data today.
Related: Top Competitor Price Tracking Tools | Price Intelligence for Ecommerce
FAQ’s
1. What is the general process for extracting data from Walmart’s website?
Find product URLs in the sitemaps Walmart lists in its robots.txt, fetch each product page politely, parse the JSON in the __NEXT_DATA__ script tag, and write the fields (name, price, rating) to CSV. The Python walkthrough above does each step.
2. Can Walmart data extraction be done with Python and BeautifulSoup?
Yes. Many developers use Python libraries like requests, BeautifulSoup, or JSON parsing via <script id="__NEXT_DATA__"> to extract product details, such as names, prices, and reviews, from Walmart pages.
3. What challenges should I expect when scraping Walmart data?
Expect bot challenges and block pages. In our own test on 16 October 2026, two plain requests were redirected to Walmart’s block page. Expect key paths in the JSON to change too, and search pages are disallowed in robots.txt.
4. What are best practices to avoid getting blocked when scraping Walmart?
Make fewer, slower requests: discover URLs through sitemaps instead of search, cache what you have fetched, and keep to one request every few seconds. Parse the __NEXT_DATA__ JSON rather than HTML selectors. When Walmart serves a block page, stop. Rotating proxies to get past it is exactly the access against a stated refusal that makes collection contested. If you need volume, use a managed provider or Walmart’s own programs.
5. Are there tools or APIs that simplify extracting Walmart data?
Yes. Services such as Bright Data, Oxylabs, Apify, and others offer scraping APIs tailored for Walmart. These services manage proxies and data parsing, making it easier to extract structured fields like price, availability, and reviews. Walmart’s own developer portal runs programs for marketplace partners and suppliers; see how marketplace APIs compare with custom extraction. For a one-off analysis, check whether free and paid ecommerce datasets already carry the fields you need before you build anything.
6. What types of data can be extracted from Walmart product pages?
Common data points include:
- Product title, URL, price, currency, image URL
- Ratings, review counts, availability, specifications, seller info
APIs vary in which fields they support.
7. Why use Forage AI for Walmart data extraction instead of DIY methods?
Forage AI is an end-to-end managed data pipeline that automates discovery, extraction, structuring, quality checks and delivery, built to your own fields and systems, with client-specific handling rules agreed up front. Your team stops maintaining scrapers and key paths.
By Manpreet Dhanjal