如何在grequests中遵循重定向?
How to follow redirect in grequests?
如何在 grequests 中跟随重定向?
在请求库中,我们可以简单地使用:r = requests.get(url, allow_redirects=True)
允许重定向。
grequests里有什么吗?
我检查了 https://pypi.org/project/grequests/ 但没有找到任何东西。
就
grequests.get(u, allow_redirects=True)
就可以了,根据它的源码,所有的参数都传给了session.request
https://github.com/kennethreitz/grequests/blob/master/grequests.py#L71
是的,您可以对 grequests
采用相同的模式。如果您查看 grequests
class,您会发现 send
方法本身将调用委托给实际的 request.Session().request
方法。所以你可以做
rs = grequests.get(u, allow_redirects=True)
如何在 grequests 中跟随重定向?
在请求库中,我们可以简单地使用:r = requests.get(url, allow_redirects=True)
允许重定向。
grequests里有什么吗?
我检查了 https://pypi.org/project/grequests/ 但没有找到任何东西。
就
grequests.get(u, allow_redirects=True)
就可以了,根据它的源码,所有的参数都传给了session.request https://github.com/kennethreitz/grequests/blob/master/grequests.py#L71
是的,您可以对 grequests
采用相同的模式。如果您查看 grequests
class,您会发现 send
方法本身将调用委托给实际的 request.Session().request
方法。所以你可以做
rs = grequests.get(u, allow_redirects=True)