Changing the referer URL in python requests

According to http://docs.python-requests.org/en/latest/user/advanced/#session-objects , you should be able to do:

s = requests.Session()
s.headers.update({'referer': my_referer})
s.get(url)

Or just:

requests.get(url, headers={'referer': my_referer})

Your headers dict will be merged with the default/session headers. From the docs:

Any dictionaries that you pass to a request method will be merged with
the session-level values that are set. The method-level parameters
override session parameters.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)