[Solved] How to get product price from json [closed]


What happens?

You try to find a price in the json, but there is no price information available.

How to get the price?

You have to call another api with the productId per item:

requests.get('https://www.adidas.com/api/search/product/'+item['productId'],headers=headers)  

Example

import requests

url = "https://www.adidas.com/api/plp/content-engine?"

params = {
    'sitePath': 'us',
    'query': 'women-athletic_sneakers'
}

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}

res = requests.get(url,params=params,headers=headers)
data=res.json()

for item in res.json()['raw']['itemList']['items']:
    itemRes = requests.get('https://www.adidas.com/api/search/product/'+item['productId'],headers=headers)    
    print(item['displayName'],item['link'],itemRes.json()['price'])

Output

Ultraboost OG Shoes /us/ultraboost-og-shoes/GX5370.html 200 
Super Super Sleek 72 Shoes /us/super-super-sleek-72-shoes/GX2769.html 140 
Forum Mid Shoes /us/forum-mid-shoes/GW2857.html 150 
Forum Mid Shoes /us/forum-mid-shoes/GW2858.html 150 
Ultraboost 21 Shoes /us/ultraboost-21-shoes/FY0403.html 180 
Ultraboost 21 Shoes /us/ultraboost-21-shoes/FY0432.html 180 
Ultraboost 21 Shoes /us/ultraboost-21-shoes/FZ2762.html 180 
Ultraboost 21 Shoes /us/ultraboost-21-shoes/FY0402.html 180

1

solved How to get product price from json [closed]