set cookie in python requests 1

set cookie in python requests

import requests

cookies = {'enwiki_session': '17ab96bd8ffbe8ca58a78657a918558'}

r = requests.post('http://wikipedia.org', cookies=cookies)

Here is what the above code is Doing:
1. Create a dictionary called cookies that contains a key enwiki_session and a value of 17ab96bd8ffbe8ca58a78657a918558.
2. Make a POST request to http://wikipedia.org and pass in the cookies dictionary as the value for the cookies parameter.
3. Store the response object in a variable called r.

Similar Posts