需要请求的url:http://list.tmall.hk/search_prod ... 455551638410_519345
请求执行的代码:
try:
url = 'http://list.tmall.hk/search_product.htm?spm=a2231.7718719.2014120101.4.679012fe39jnPw&cat=51256001&auction_tag=13186&acm=lb-zebra-34359-425807.1003.8.519345&scm=1003.8.lb-zebra-34359-425807.ITEM_14455551638410_519345'
opener = urllib.request.build_opener(HTTPCookieRedirectHandler)
proxy_parms = {"http": "127.0.0.1:8888"}
opener.add_handler(urllib.request.ProxyHandler(proxy_parms))
request = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0'})
response = opener.open(request)
print(response.geturl())
print(response.read().decode("utf-8", "ignore"))
except HTTPError as e:
print(e.code)
print(e.reason)
使用fiddler监控这次请求,发现:
请求后,它会不断重复返回302重定向,显示如下:
最终程序报出如下错误:
302
The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found
请问:我应该如何解决这个问题?
|
|
|
|
|
共 1 个关于本帖的回复 最后回复于 2018-5-13 09:43