我一直收到一个html302错误,但是我非常确定这个错误是来自这里的一些代码,我只是不知道确切的位置和如何修复它。
headers ={'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8','Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3','Accept-Encoding': 'gzip, deflate, sdch','Accept-Language': 'en-US,en;q=0.8','Connection': 'keep-alive'}
req_obj = urllib.request.Request(url, method=method,headers=headers)
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
response = opener.open(req_obj)
json_resp = json.loads(response.read().decode('utf-8'))
我得到的错误是
HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found
(False, <HTTPError 302: 'The HTTP server returned a redirect error that would lead to an infinite loop.\nThe last 30x error message was:\nFound'>)
提前感谢
发布于 2018-06-03 08:57:11
这是您试图访问的服务器的问题。标头的Location
参数与您试图访问的网址相同,这将导致无限循环。
例如,如果我要转到http://example.com/foo
,它告诉我资源已移动到http://example.com/foo
,我将按请求转到http://example.com/foo
。然而,这会告诉我http://example.com/foo
已经被移到了http://example.com/foo
。以此类推。
https://stackoverflow.com/questions/50662206
复制相似问题