How to Scrape Walmart with Python: Search, Products and Reviews
Walmart puts almost everything you want to scrape into one JSON object inside each page: product names, prices, ratings, stock status, sellers and reviews. So a Walmart scraper in Python does not need a browser or CSS selectors. It needs to fetch the page without being challenged, pull out that JSON and walk a few known paths.

This guide builds that scraper step by step: search results with pagination, product pages, reviews, retries and block detection, and CSV and JSON output. Every request and output shown below was run on November 30, 2026 through the ScrapingAnt Web Scraping API, and the full script is at the end.
Can you scrape Walmart with Python?
Yes. Walmart's search, product and review pages are server-rendered and include their data as JSON in a <script id="__NEXT_DATA__"> tag, so Python's requests and the standard json module are enough to extract it once you can fetch the page.
The hard part is the fetch. Walmart runs bot protection, and requests from datacenter IPs with default headers are often answered with a challenge page instead of the store page. Other guides describe that page as "Robot or human?" with a press-and-hold button. A scraping API handles the proxies and browser fingerprints, and returns the page HTML to your script.
In our runs on November 30, 2026, plain requests through the Web Scraping API (no browser, 1 credit each) returned the full page with __NEXT_DATA__ for search pages one to six, several different product pages and three review pages. We did not hit a challenge page in that mode. One request out of about 35 failed with a dropped connection and succeeded on retry. That is a snapshot of one day, not a guarantee, so the scraper below detects blocks and escalates to more expensive modes when it needs to.
What data can you scrape from Walmart?
From public Walmart pages you can extract product name, ID, brand, current and previous price, rating, review count, availability, seller, image URLs and individual reviews. Here is where each piece lives:
| Page | URL pattern | Useful fields |
|---|---|---|
| Search | walmart.com/search?q=QUERY&page=N | Name, ID, price, rating, review count, availability, seller, product URL |
| Product | walmart.com/ip/ITEM_ID | Brand, current and was price, availability, description, images |
| Reviews | walmart.com/reviews/product/ITEM_ID?page=N | Rating, title, text, date, plus rating breakdown |
Stick to public pages that need no login. Prices and availability on Walmart depend on the store and ZIP code the site picks for the visitor, so treat a price as "the price shown to this request", not a national price.
How do I set up a Walmart scraper in Python?
You need Python 3.9 or newer, the requests library and a ScrapingAnt API key in an environment variable. Everything else is the standard library.
pip install requests
export SCRAPINGANT_API_KEY="your-api-key"
The free plan includes 10,000 API credits a month, enough for thousands of the 1-credit requests used below.
How do I fetch a Walmart page without getting blocked?
Send the Walmart URL to the Web Scraping API with browser=false first: it is the cheapest mode and, in our tests, it returned complete Walmart pages. Then check that the response contains __NEXT_DATA__ and none of the challenge page markers.
import json
import os
import re
import requests
API_URL = "https://api.scrapingant.com/v2/general"
API_KEY = os.environ["SCRAPINGANT_API_KEY"]
NEXT_DATA = re.compile(r'<script id="__NEXT_DATA__"[^>]*>(.*?)</script>', re.S)
r = requests.get(API_URL, params={
"url": "https://www.walmart.com/search?q=air+fryer",
"x-api-key": API_KEY,
"browser": "false",
}, timeout=180)
data = json.loads(NEXT_DATA.search(r.text).group(1))
print(r.status_code, r.headers["Ant-page-status-code"], r.headers["Ant-credits-cost"])
print(list(data["props"]["pageProps"]["initialData"]["searchResult"].keys())[:8])
200 200 1
['title', 'aggregatedCount', 'searchRedirect', 'breadCrumb', 'debug', 'itemStacks', 'nonProduct', 'categoryNavigation']
Three headers tell you what happened:
- The HTTP status of the API response itself:
200means the API got a page,423means the target site detected the request. Ant-page-status-code: the status Walmart returned. A product that no longer exists gives404here while the API call is still200.Ant-credits-cost: what the request cost. Log it to keep track of spend.
Note that browser defaults to true in the API. If you leave it out, every request runs a headless browser and costs 10 credits instead of 1.
Where is the data on a Walmart page?
All three page types store their data under props.pageProps.initialData in the __NEXT_DATA__ JSON. Search results sit in searchResult.itemStacks, product details in data.product, and reviews in data.reviews.

The JSON is large (search pages were 1.1 to 1.7 MB of HTML in our runs), so do not print it whole. Explore it with .keys() one level at a time, or save it to a file and open it in an editor that folds JSON. Walmart changes these structures from time to time, which is why the parsers below use .get() and fail softly on missing fields.
How do I scrape Walmart search results?
Read searchResult.itemStacks, keep the items whose __typename is Product, and take the fields you need. paginationV2.maxPage tells you how many pages the search has.
def parse_search(data):
result = data["props"]["pageProps"]["initialData"]["searchResult"]
products = []
for stack in result["itemStacks"]:
for item in stack["items"]:
if item.get("__typename") != "Product":
continue # skip ads, banners and other tiles
products.append({
"id": item.get("usItemId"),
"name": item.get("name"),
"price": item.get("price"),
"rating": item.get("averageRating"),
"reviews": item.get("numberOfReviews"),
"availability": item.get("availabilityStatusDisplayValue"),
"seller": item.get("sellerName"),
"url": "https://www.walmart.com" + item["canonicalUrl"].split("?")[0],
})
return products, result["paginationV2"]["maxPage"]
products, max_page = parse_search(data)
print(len(products), "products, pages:", max_page)
print(products[0])
59 products, pages: 13
{'id': '6077911929', 'name': 'Ninja Crispi Glass Air Fryer 4-Qt, 3-in-1, Air Fry Recrisp, Portable, Dishwasher Safe, FN100WH White', 'price': 134, 'rating': 4.5, 'reviews': 4904, 'availability': 'In stock', 'seller': 'Walmart.com', 'url': 'https://www.walmart.com/ip/Ninja-Crispi-Glass-Air-Fryer-4-Qt-3-in-1-Air-Fry-Recrisp-Portable-Dishwasher-Safe-FN100WH-White/6077911929'}
The price field is a number. If you need the strike-through price as well, each search item also has a priceInfo.priceDetails.priceLines list with entries such as DISCOUNTED_PRICE and WAS_PRICE.
How do I handle pagination on Walmart?
Add &page=N to the search URL and stop at maxPage. Sponsored products repeat across pages, so deduplicate by product ID.
from urllib.parse import quote_plus
def search(query, max_pages=2):
rows, seen = [], set()
for page in range(1, max_pages + 1):
data = fetch(f"https://www.walmart.com/search?q={quote_plus(query)}&page={page}")
products, last_page = parse_search(data)
for p in products:
if p["id"] not in seen:
seen.add(p["id"])
rows.append(p)
if page >= last_page:
break
return rows
fetch() is the retrying function shown further down. In our run, two pages of "air fryer" gave 88 unique products. We fetched pages one to six of a "tv" search the same way, each with one 1-credit request.
How do I scrape a Walmart product page?
Fetch https://www.walmart.com/ip/ITEM_ID and read initialData.data.product. Prices are under priceInfo.currentPrice and priceInfo.wasPrice.
def parse_product(data):
product = data["props"]["pageProps"]["initialData"]["data"]["product"]
price = product.get("priceInfo") or {}
return {
"id": product.get("usItemId"),
"name": product.get("name"),
"brand": product.get("brand"),
"price": (price.get("currentPrice") or {}).get("price"),
"was_price": (price.get("wasPrice") or {}).get("price"),
"rating": product.get("averageRating"),
"reviews": product.get("numberOfReviews"),
"availability": product.get("availabilityStatus"),
"image": (product.get("imageInfo") or {}).get("thumbnailUrl"),
}
print(parse_product(fetch("https://www.walmart.com/ip/6077911929")))
https://www.walmart.com/ip/6077911929 -> 200, 1 credit(s)
{'id': '6077911929', 'name': 'Ninja Crispi Glass Air Fryer 4-Qt, 3-in-1, Air Fry Recrisp, Portable, Dishwasher Safe, FN100WH White', 'brand': 'Ninja', 'price': 134, 'was_price': 149, 'rating': 4.5, 'reviews': 4904, 'availability': 'IN_STOCK', 'image': 'https://i5.walmartimages.com/seo/Ninja-Crispi-Glass-Air-Fryer-4-Qt-...jpeg'}
The product object has much more: shortDescription, imageInfo.allImages, variant data and specifications. The short product URL with only the item ID works as well as the long one from search results.
How do I scrape Walmart reviews?
Fetch https://www.walmart.com/reviews/product/ITEM_ID and read initialData.data.reviews.customerReviews. Each page has 10 reviews, and pagination.next is set while there are more.
def parse_reviews(data):
reviews = data["props"]["pageProps"]["initialData"]["data"]["reviews"]
items = [
{
"rating": r.get("rating"),
"title": r.get("reviewTitle"),
"text": r.get("reviewText"),
"date": r.get("reviewSubmissionTime"),
}
for r in reviews["customerReviews"]
]
return items, reviews["pagination"]["next"] is not None
page, all_reviews = 1, []
while page <= 3:
items, has_next = parse_reviews(fetch(f"https://www.walmart.com/reviews/product/6077911929?page={page}"))
all_reviews.extend(items)
if not has_next:
break
page += 1
{'rating': 5, 'title': 'Love !', 'text': "This is a very good investment saves time and easy to clean. ...", 'date': '7/18/2026'}
The same reviews object also carries the rating breakdown (ratingValueFiveCount and the rest), totalReviewCount and reviewsWithTextCount. For the product above those were 4,904 ratings and 1,008 written reviews, which is why the review count on the product page is higher than the number of reviews you can page through.
How do I detect when Walmart blocks the scraper?
Treat a response as blocked when the API returns 423, or when the HTML has no __NEXT_DATA__ or contains challenge markers such as "Robot or human". Retry the same mode once, then move to the next, more expensive mode.

import time
# Cheapest first: 1, 10 and 25 credits
MODES = [
{"browser": "false"},
{"browser": "true"},
{"browser": "false", "proxy_type": "residential"},
]
BLOCK_MARKERS = ("Robot or human", "px-captcha")
class Blocked(Exception):
pass
def fetch(url, tries_per_mode=2):
for mode in MODES:
for attempt in range(1, tries_per_mode + 1):
try:
r = requests.get(API_URL, params={"url": url, "x-api-key": API_KEY, **mode}, timeout=180)
except requests.RequestException as e:
print(f" {mode} attempt {attempt}: {type(e).__name__}")
time.sleep(2 * attempt)
continue
if r.status_code == 200:
match = NEXT_DATA.search(r.text)
if match and not any(m in r.text for m in BLOCK_MARKERS):
print(f"{url} -> {r.headers.get('Ant-page-status-code')}, {r.headers.get('Ant-credits-cost')} credit(s)")
return json.loads(match.group(1))
print(f" {mode} attempt {attempt}: challenge page or no data")
else:
print(f" {mode} attempt {attempt}: API status {r.status_code}")
time.sleep(2 * attempt)
raise Blocked(url)
What we saw when we tried the other modes on November 30, 2026:
browser=true(10 credits): returned a search page in 9 seconds and a product page in 39 seconds. One earlier product request ran past our 200-second client timeout.proxy_type=residential, no browser (25 credits): a search page came back in 14 seconds. On a product page, one request got423("Our browser was detected by target site") and a second succeeded, slowly.
So for Walmart, the cheap mode was also the fastest and most dependable in our runs. Keep the escalation anyway: anti-bot behavior changes, and a scraper that only knows one mode stops the day that mode stops working. Requests that fail at the API cost no credits.
How much does it cost to scrape Walmart?
Each successful request costs 1 API credit without a browser, 10 with a headless browser and 25 with a residential proxy, per ScrapingAnt's credit cost table. One Walmart page is one request.

| Request mode | Credits per page | Pages on the free plan (10,000 credits) | Cost per 1,000 pages on Startup ($49 for 500,000 credits) |
|---|---|---|---|
browser=false | 1 | 10,000 | $0.10 |
browser=true | 10 | 1,000 | $0.98 |
proxy_type=residential, browser=false | 25 | 400 | $2.45 |
A practical estimate: tracking 1,000 products daily means about 30,000 product page requests a month. In plain mode that is 30,000 credits, plus whatever escalations your log shows. Our whole test for this article, including the slow and failed mode checks, used under 120 credits.
What does the complete Walmart scraper look like?
Below is the full script: search with pagination, product pages for the top results, retries with mode escalation, and CSV and JSON output. Save it as walmart_scraper.py and run python walmart_scraper.py.
import csv
import json
import os
import re
import time
from urllib.parse import quote_plus
import requests
API_URL = "https://api.scrapingant.com/v2/general"
API_KEY = os.environ["SCRAPINGANT_API_KEY"]
MODES = [
{"browser": "false"},
{"browser": "true"},
{"browser": "false", "proxy_type": "residential"},
]
NEXT_DATA = re.compile(r'<script id="__NEXT_DATA__"[^>]*>(.*?)</script>', re.S)
BLOCK_MARKERS = ("Robot or human", "px-captcha")
class Blocked(Exception):
pass
def fetch(url, tries_per_mode=2):
for mode in MODES:
for attempt in range(1, tries_per_mode + 1):
try:
r = requests.get(API_URL, params={"url": url, "x-api-key": API_KEY, **mode}, timeout=180)
except requests.RequestException as e:
print(f" {mode} attempt {attempt}: {type(e).__name__}")
time.sleep(2 * attempt)
continue
if r.status_code == 200:
match = NEXT_DATA.search(r.text)
if match and not any(m in r.text for m in BLOCK_MARKERS):
print(f"{url} -> {r.headers.get('Ant-page-status-code')}, {r.headers.get('Ant-credits-cost')} credit(s)")
return json.loads(match.group(1))
print(f" {mode} attempt {attempt}: challenge page or no data")
else:
print(f" {mode} attempt {attempt}: API status {r.status_code}")
time.sleep(2 * attempt)
raise Blocked(url)
def parse_search(data):
result = data["props"]["pageProps"]["initialData"]["searchResult"]
products = []
for stack in result["itemStacks"]:
for item in stack["items"]:
if item.get("__typename") != "Product":
continue
products.append({
"id": item.get("usItemId"),
"name": item.get("name"),
"price": item.get("price"),
"rating": item.get("averageRating"),
"reviews": item.get("numberOfReviews"),
"availability": item.get("availabilityStatusDisplayValue"),
"seller": item.get("sellerName"),
"url": "https://www.walmart.com" + item["canonicalUrl"].split("?")[0],
})
return products, result["paginationV2"]["maxPage"]
def parse_product(data):
product = data["props"]["pageProps"]["initialData"]["data"]["product"]
price = product.get("priceInfo") or {}
return {
"id": product.get("usItemId"),
"name": product.get("name"),
"brand": product.get("brand"),
"price": (price.get("currentPrice") or {}).get("price"),
"was_price": (price.get("wasPrice") or {}).get("price"),
"rating": product.get("averageRating"),
"reviews": product.get("numberOfReviews"),
"availability": product.get("availabilityStatus"),
"image": (product.get("imageInfo") or {}).get("thumbnailUrl"),
}
def search(query, max_pages=2):
rows, seen = [], set()
for page in range(1, max_pages + 1):
data = fetch(f"https://www.walmart.com/search?q={quote_plus(query)}&page={page}")
products, last_page = parse_search(data)
for p in products:
if p["id"] not in seen:
seen.add(p["id"])
rows.append(p)
if page >= last_page:
break
return rows
if __name__ == "__main__":
results = search("air fryer", max_pages=2)
details = []
for row in results[:3]:
try:
details.append(parse_product(fetch(row["url"])))
except Blocked as e:
print("skipped", e)
time.sleep(1)
with open("walmart_search.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=results[0].keys())
writer.writeheader()
writer.writerows(results)
with open("walmart_products.json", "w", encoding="utf-8") as f:
json.dump(details, f, indent=2, ensure_ascii=False)
print(f"{len(results)} search results, {len(details)} product pages saved")
Output of our run:
https://www.walmart.com/search?q=air+fryer&page=1 -> 200, 1 credit(s)
https://www.walmart.com/search?q=air+fryer&page=2 -> 200, 1 credit(s)
https://www.walmart.com/ip/3L-Air-Fryer-with-Viewing-Window-Digital-Touch-Controls-8-Preset-Menus-Black/20873503687 -> 200, 1 credit(s)
https://www.walmart.com/ip/New-Gourmia-1700W-6-Slice-Digital-Toaster-Oven-Air-Fryer-With-19-One-Touch-Presets-Stainless-Steel/1438286796 -> 200, 1 credit(s)
https://www.walmart.com/ip/Gourmia-4-Quart-Digital-Air-Fryer-with-12-One-Touch-Presets-New-GAF414-12-in-High/3298701757 -> 200, 1 credit(s)
88 search results, 3 product pages saved
The first lines of walmart_search.csv:
id,name,price,rating,reviews,availability,seller,url
20873503687,"3.5 Qt Air Fryer with Viewing Window, Compact 1200W Small Digital Air Fryer, 8 Presets, ...",53.99,4.9,95,In stock,Amumu Direct,https://www.walmart.com/ip/3L-Air-Fryer-...-Black/20873503687
1438286796,"Gourmia French Door 6-Slice Digital Toaster Oven Air Fryer, 19 One-Touch Presets, 24L, Stainless Steel",89.97,4.4,15233,In stock,Walmart.com,https://www.walmart.com/ip/New-Gourmia-...-Stainless-Steel/1438286796
Five requests, five credits, and a CSV you can open in any spreadsheet. To track prices over time, run it on a schedule and append a timestamp column.
How do I scale a Walmart scraper?
Scale by running requests in parallel, keeping one product per row with a timestamp, and logging the credit cost and page status of every request. A thread pool is enough for most jobs:
from concurrent.futures import ThreadPoolExecutor
urls = [row["url"] for row in results]
with ThreadPoolExecutor(max_workers=10) as pool:
products = list(pool.map(lambda u: parse_product(fetch(u)), urls))
ScrapingAnt paid plans have no concurrency limit, so the practical limit is what is reasonable for the target site. Start low, watch the share of escalated or blocked requests in your log, and back off when it rises. Cache product pages you fetched recently, and use search pages to spot price changes before you refetch product pages: one search page covers dozens of products for 1 credit.
Is it legal to scrape Walmart?
Scraping publicly visible product data is common practice, but whether it is allowed in your case depends on your jurisdiction, what you collect and how you use it. This is not legal advice. Read Walmart's terms of use, collect only public data that needs no login, do not collect personal information about reviewers beyond what you need, and keep your request rate modest. If the data is business-critical, ask a lawyer.
Key takeaways
- Walmart search, product and review pages carry their data in the
__NEXT_DATA__JSON, so you can skip the browser and CSS selectors. - Paths:
searchResult.itemStacksfor search,data.productfor products,data.reviewsfor reviews, all underprops.pageProps.initialData. - Through the Web Scraping API, a plain request (1 credit) returned every Walmart page type we tried on November 30, 2026.
- Detect blocks by status
423, a missing__NEXT_DATA__or challenge text, and escalate to a browser or residential proxy only for those URLs. - Deduplicate search results by product ID and log
Ant-credits-costandAnt-page-status-codefor every request.
To run the scraper above, get an API key on the ScrapingAnt free plan and see the Web Scraping API for request options and plans.