req = response.request req_headers = req.__dict__['headers'] referer_url = req_headers['Referer'].decode('utf-8')