import time
import requests
r = requests.get('http://github.com/', allow_redirects=False)
# Don't fetch the next page too quickly
time.sleep(3)
# Now go to the URL that the previous request would have gone to
# if you hadn't asked requests.get not to.
r = requests.get(r.headers['Location'])
2条答案
按热度按时间qmelpv7a1#
这个
requests
模块有一个用于配置的参数allow_redirects
如果您需要遵循重定向的300系列响应。https://docs.python-requests.org/en/master/user/quickstart/#redirection-历史
rjee0c152#
在这种情况下,您可以先睡一会儿,然后手动访问下一个位置: