2

Here is what I am looking for.

s = Session()    

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

def do_this(self, response):
    print response.url
Talha Ashraf
  • 1,085
  • 1
  • 13
  • 19

2 Answers2

4

You can use event hooks:

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


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

s.get(...)

Documentation here: https://requests.kennethreitz.org/en/master/user/advanced/#event-hooks

Kyle James Walker
  • 1,171
  • 12
  • 16
2

Use grequests to have asynchronous requests with gevent. There is a callback keyword argument to .get().

mguijarr
  • 7,281
  • 5
  • 40
  • 71