Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getProduct():
- session = requests.session()
- url = "https://prod.jdgroupmesh.cloud/stores/footpatrolgb/products/346297_footpatrolcom?channel=iphone-app&expand=variations,informationBlocks,customisations"
- hawkHeader = makeHawkHeader(url, "GET")
- headers = {
- 'Host': 'prod.jdgroupmesh.cloud',
- 'mesh-version': 'cart=4',
- 'MESH-Commerce-Channel': 'iphone-app',
- # 'X-Request-Auth': makeHawkHeader(url, "GET"),
- 'X-Request-Auth': hawkHeader,
- 'X-API-Key': '52F096E285134DF2A9E1AFAF979BB415',
- 'Accept-Language': 'en-gb',
- 'Accept-Encoding': 'gzip, deflate',
- 'Accept': '*/*',
- 'User-Agent': 'footpatrolgb/6.3.2.1446 (iphone-app; iOS 12.4.1)',
- 'X-Debug': '1',
- 'Connection': 'close',
- 'X-NewRelic-ID': 'VQYDUFVWDRABUFJQAwQHVFw=',
- }
- proxies = {"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"}
- productReq = session.get(url, headers=headers, verify=False, proxies=proxies)
- print(productReq)
- print(productReq.text)
- def signature(url,method):
- secret = str.encode('')
- h = base64.urlsafe_b64encode(os.urandom(6))
- content = ''.join(chr(x) for x in h)
- options = {
- "ts": int(time.time()),
- "nonce": content,
- "method": method,
- "resource": "/stores/footpatrolgb/products/346297_footpatrolcom?channel=iphone-app&expand=variations,informationBlocks,customisations",
- "host": "prod.jdgroupmesh.cloud",
- "port": "80",
- }
- hash_items = [
- "hawk.1.header",
- options["ts"], # Timestamp
- options["nonce"], # Random nonce
- options.get("method", "").upper(), # UPPERCASE HTTP method
- options.get("resource", ""),
- options["host"].lower(),
- options["port"],
- "",
- "",
- "",
- ]
- hash_items = map(str, hash_items)
- hash_str = '\n'.join(hash_items)
- # Generate HMAC using sha256
- h = base64.b64encode(hmac.new(secret, hash_str.encode('utf-8'), hashlib.sha256).digest())
- mac = ''.join(chr(x) for x in h)
- return mac, options
- def makeHawkHeader(url, method):
- key = ""
- mac, options = signature(url, method)
- header_items = [
- 'id="%s"' % key,
- 'ts="%s"' % options["ts"],
- 'nonce="%s"' % options["nonce"],
- ]
- if options.get("ext", None):
- header_items.append('ext="%s"' % options["ext"])
- header_items.append('mac="%s"' % mac)
- return 'Hawk ' + ', '.join(header_items)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement