假设我在URL上执行GET请求(例如:http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398),并且我跟踪请求:
response = requests.get(url, timeout=10)
if response.history:
print("Request was redirected")
for resp in response.history:
print("Status code, URL: {}, {}".format(resp.status_code, resp.url))
print("Final destination:")
print("Status code, URL: {}, {}".format(resp.status_code, response.url))
else:
print("Request was not redirected")
输出结果为:
Request was redirected
Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398
Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398?cookieSet=1
Final destination:
Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398
我想知道一些事情:
答案 0 :(得分:0)
询问网站程序员。
当然,每个请求都需要一些时间。
是的,你可以。
可能会话会减少重定向