python-requests 有回调方法吗?

Tal*_*raf 4 python gevent python-requests

这就是我正在寻找的东西。

s = Session()    

s.get(url, callback=self.do_this)

def do_this(self, response):
    print response.url
Run Code Online (Sandbox Code Playgroud)

Kyl*_*ker 6

您可以使用事件挂钩:

def display_url(r, **kwargs):
    print(r.url)


s = Session()
s.hooks['response'].append(display_url)

s.get(...)
Run Code Online (Sandbox Code Playgroud)

此处的文档:https ://requests.kennethreitz.org/en/master/user/advanced/#event-hooks