问题描述:
通过http请求get请求,服务器返回 timestamp not allowed
而另一台电脑则是可以的
分析:
其实就是时间戳有问题,经过无数次尝试与问人,快要奔溃了
问题解决:
1、重新安装pycharm 不行…
2、重启电脑n多次也不行
3、分析代码 打印时间戳值,也是没问题
4、修改电脑时间,同步一下,果然可以了 这种问题太隐蔽了
进入点击同步时间
大功告成
部分代码:
currTimes = time.time();
print(currTimes)
print(time.localtime(time.time()))
print(time.asctime(time.localtime(time.time())))
#timestamp = int(round(currTimes * 1000));
timestamp = int(round(currTimes*1000))
print(timestamp)
headers = {'Accept': Accept,
'signature': signature,
'User-Agent': UserAgent,
'appKey': appKey,
'Accept-Encoding': AcceptEncoding,
'Accept-Language': AcceptLanguage,
'Content-Type': getContentType,
'timestamp': timestamp
};
#print(headers);
req = urllib.request.Request(ApiDomain + ActionController + "?" + getParamdata , None, headers, method="GET");
# 打开请求,获取对象
response = urllib.request.urlopen(req);
#print(type(response)) # 打印
#print(response) # 打印
# 打印Http状态码
#print(response.status) ;# 打印200
# 读取服务器返回的数据,对HTTPResponse类型数据进行读取操作
the_page = response.read();
# 中文编码格式打印数据
return(the_page.decode("utf-8"));