I'm trying to scrape brand suggestions from https://keepa.com/#!finder For example when you're typing 'ni' in field "brand" the list with suggestions appears. It includes all brands started with 'ni' like 'nike'. 
I know that a websocket session is responsible for that. When you press a key, it sends gzipped JSON string to that session and receives response like this.
So the yellow items are gzipped strings. When I'm trying to recreate this in Python, it fails. The following code
from websocket import create_connection
import zlib
websocket_resource_url = 'wss://dyn.keepa.com/apps/cloud/?app=keepaWebsite&version=1.6'
ws = create_connection(websocket_resource_url)
msg = {"path":"pro/autocomplete","content":"nike","domainId":1,"maxResults":25,"type":"brand","version":3,"id":111111,"user":"user"}
ws.send(zlib.compress((json.dumps(msg)+'\n').encode('utf-8')))
print('Result: {}'.format(zlib.decompress(ws.recv())))
returns {"status":108, "n":73} But expected output is somethins like:
{"startTimeStamp":1637576348774,"id":7596,"timeStamp":1637576348774,"status":200,"version":3,"lastUpdate":0,"suggestions":[{"value":"nike","count":1100713},{"value":"nike golf","count":7497},{"value":"nikeelando","count":358},{"value":"nikea","count":195},{"value":"nike sb","count":87}]}
What I'm doing wrong?
Aucun commentaire:
Enregistrer un commentaire