I'm trying to use ajax to query the supermarket's search API, and reply with the name, price and the unit pricing. To do this using Python requests, I would use this code:
import requests
import json
payload ={
'Filters':'[]',
'IsSpecial':'false',
'Location':'/shop/search/products?searchTerm=banana',
'PageNumber':'1',
'PageSize':'24',
'SearchTerm':'banana',
'SortType':'TraderRelevance'
}
url = "https://www.woolworths.com.au/apis/ui/Search/products"
data = requests.post(url, json=payload).json()
print(data['Products'][0]['Name'])
print("$", data['Products'][0]['Products'][0]['Price'], "0", sep='')
print(data['Products'][0]['Products'][0]['CupString'])
print()
print(data['Products'][1]['Name'])
print("$", data['Products'][1]['Products'][0]['Price'], "0", sep='')
print(data['Products'][1]['Products'][0]['CupString'])
print()
print(data['Products'][2]['Name'])
print("$", data['Products'][0]['Products'][2]['Price'], "0", sep='')
print(data['Products'][0]['Products'][2]['CupString'])
print()
And so on...
What I am trying to do is replicate this python code to something that can be used in a web browser. Is that something that is possible?