One mobile app I am trying to scrape accepts b64 encoded requests. I tried the following:
post_data = {
"id": iv,
"command": "queryDoc",
"params": {
"pageNum": "1",
"sortFields": "s50:desc",
"ciphertext": make_ciphertext(),
"devid": "d607f6d3de0f4f68b44aae416592f559",
"devtype": "1",
"pageSize": "20",
"queryCondition": [{"key":"s21","value":"2020"}]
}
}
post_data_encoded = base64.b64encode(json.dumps(post_data).encode())
print (post_data_encoded)
with requests.post(url, headers=headers, data=post_data_encoded) as req:
print (req.json())
However, the response reads:
{
"data": {},
"ret": {
"code": 9,
"msg": "Input byte array has incorrect ending byte at 900"
}
}
I tried to decode the real requests from my phone browser, and it yielded a dictionary with all the same parameters. What could be going wrong here?
I did look at a similar issue here: Input byte array has incorrect ending byte at 40
Could it be that b64encode in Python outputs differently than java.util.Base64
? I appreciate any suggestion.