La recherche sur le Walmart Marketplace est plus difficile que sur Amazon car moins d'outils la prennent en charge. Ce tutoriel construit un pipeline de recherche qui parcourt les produits Walmart, suit les prix, identifie les meilleurs vendeurs et repère les lacunes dans la couverture des produits. Chaque requête coûte $0.005 via la recherche de plateforme Walmart de l'API Scavio.
Prérequis
- Python 3.8+
- bibliothèque requests
- Une clé API Scavio depuis scavio.dev
- Catégories de produits à rechercher
Parcours
Étape 1: Rechercher des produits Walmart par catégorie
Interroger les listes de produits Walmart et extraire des données structurées.
import os, requests, json
from datetime import datetime
from collections import Counter, defaultdict
API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
def search_walmart(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'platform': 'walmart', 'country_code': 'us'}, timeout=10).json()
products = []
for r in data.get('organic_results', []):
products.append({
'title': r.get('title', ''),
'link': r.get('link', ''),
'price': r.get('price', r.get('extracted_price', '')),
'rating': r.get('rating', ''),
'seller': r.get('source', r.get('displayed_link', '')),
'position': r.get('position', 0),
})
return products
CATEGORIES = [
'organic protein powder',
'wireless security camera outdoor',
'kids educational tablet',
]
all_products = {}
for cat in CATEGORIES:
products = search_walmart(cat)
all_products[cat] = products
print(f'\n{cat}: {len(products)} products')
for p in products[:3]:
print(f' #{p["position"]} {p["title"][:45]}')
print(f' Price: {p["price"]} | Seller: {p["seller"][:25]}')
print(f'\nCost: ${len(CATEGORIES) * 0.005:.3f}')Étape 2: Analyser le paysage des vendeurs
Identifier les meilleurs vendeurs, les fourchettes de prix et le positionnement sur le marché.
def analyze_category(category, products):
if not products:
return
sellers = Counter(p['seller'] for p in products if p['seller'])
prices = []
for p in products:
try:
price = float(str(p['price']).replace('$', '').replace(',', '').split('-')[0].strip())
prices.append(price)
except (ValueError, IndexError):
pass
print(f'\n=== {category} ===')
print(f' Products found: {len(products)}')
if prices:
print(f' Price range: ${min(prices):.2f} - ${max(prices):.2f}')
print(f' Avg price: ${sum(prices)/len(prices):.2f}')
print(f' Median price: ${sorted(prices)[len(prices)//2]:.2f}')
print(f' Top sellers:')
for seller, count in sellers.most_common(5):
print(f' {seller[:30]:30} | {count} products')
# Price tiers
if prices:
budget = sum(1 for p in prices if p < sum(prices)/len(prices) * 0.7)
mid = sum(1 for p in prices if sum(prices)/len(prices) * 0.7 <= p <= sum(prices)/len(prices) * 1.3)
premium = sum(1 for p in prices if p > sum(prices)/len(prices) * 1.3)
print(f' Price tiers: Budget {budget} | Mid {mid} | Premium {premium}')
for cat, products in all_products.items():
analyze_category(cat, products)Étape 3: Trouver les lacunes et opportunités de produits
Comparer les résultats Walmart avec Amazon pour trouver des catégories mal desservies.
def find_gaps(categories):
print(f'\n=== Walmart vs Amazon Gap Analysis ===')
for cat in categories:
walmart = search_walmart(cat)
amazon_data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': cat, 'platform': 'amazon', 'country_code': 'us'}, timeout=10).json()
amazon = amazon_data.get('organic_results', [])
wm_count = len(walmart)
am_count = len(amazon)
print(f'\n {cat[:40]}')
print(f' Walmart: {wm_count} results | Amazon: {am_count} results')
if wm_count < am_count:
print(f' GAP: Walmart has fewer options. Opportunity for sellers.')
elif wm_count > am_count:
print(f' Walmart has more competition than Amazon.')
else:
print(f' Similar competition levels.')
print(f'\n Total cost: ${len(categories) * 2 * 0.005:.3f} (Walmart + Amazon per category)')
print(f' Monthly (daily scans): ${len(categories) * 2 * 0.005 * 30:.2f}')
find_gaps(CATEGORIES)Exemple Python
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def walmart_search(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'platform': 'walmart', 'country_code': 'us'}, timeout=10).json()
for r in data.get('organic_results', [])[:3]:
print(f'{r.get("title", "")[:45]} | {r.get("price", "N/A")}')
walmart_search('organic protein powder')
print('Cost: $0.005')Exemple JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH,
body: JSON.stringify({ query: 'organic protein powder', platform: 'walmart', country_code: 'us' })
}).then(r => r.json());
(data.organic_results || []).slice(0, 3).forEach(r => {
console.log(`${r.title?.slice(0, 45)} | ${r.price || 'N/A'}`);
});Sortie attendue
organic protein powder: 10 products
#1 Orgain Organic Plant Based Protein Powder
Price: $27.98 | Seller: walmart.com
#2 Garden of Life Raw Organic Protein
Price: $32.49 | Seller: walmart.com
=== organic protein powder ===
Products found: 10
Price range: $18.99 - $54.99
Avg price: $31.50
Top sellers:
walmart.com | 6 products
amazon.com | 2 products
=== Walmart vs Amazon Gap Analysis ===
organic protein powder
Walmart: 10 results | Amazon: 10 results
Total cost: $0.030