python - Python莫霍克错误。返回“异常”消息
问题描述
我一直在使用 Python Mohawk 并不断收到响应 {"error":{"message":"Exception."}}。我最初遇到 API 密钥问题,但通过重新排列 X-Request-Auth 标头解决了这个问题。
下面提供的代码摘要。
from mohawk import Sender
import requests
url = 'https://prod.jdgroupmesh.cloud/stores/jdsportsjx/products/415676/reviews?channel=android-app-tablet'
method = 'GET'
sender = Sender({'id': '850216d081', 'key': '1F13108153574B20866A02BE3D7578E5', 'algorithm': 'sha256'}, url, method, always_hash_content=False, content='', content_type='')
h = sender.request_header.split(", ")
#print(h)
token = h[2] + ", " + h[0] + ", " + h[3] + ", " + h[4]
head = {
'X-NewRelic-ID': 'VQYDUFVWDRABVlVTDwkDU1U=',
'x-api-key': '1F13108153574B20866A02BE3D7578E5',
'MESH-Commerce-Channel': 'android-app-tablet',
'mesh-version': 'cart=4',
'User-Agent': 'jdsportsjx/6.2.7.8361 (android-app-tablet; Android 7.1.2; Build/NRD90M.G955FXXU1AQJ5)',
'X-Request-Auth': token,
'Host': 'prod.jdgroupmesh.cloud',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
}
r = requests.get(url,headers=head)
print(r.text)
解决方案
推荐阅读
- python - 区间 [0,360] 中两个向量之间的角度
- python-3.x - 无法使用 PyPDF2 在 jupyter notebook 上打开我的 pdf 文件
- r - 计算R中Tobit的虚拟边际效应(及其标准误差)
- magento2 - 自动重新索引后无法应用 Magento 2 目录规则
- c# - 如何简单地添加两位小数并四舍五入到最接近的两位小数?
- python - 在 PCA 中获取两个以上特征值时出错
- php - 如何在 php 中使用 json decode 从数据库中获取数据并显示如下结果?
- nativescript - Nativescript 6.5 无法在 iOS 上构建模块“nanopb”
- json - youtube-dl:解析 JSON 失败
- java - 使用 Java JDBC 创建表的外键问题