How can all cookies be added automatically to the header? using requests
#1
how are you? I'm trying to modify the login to scrape a page so that other users can use it, but to be able to enter I need to add some cookies in the header, if I add them manually, everything works fine but when accessing as another user the value of these changes and it does not work.
My code is like this:
Code:
s = requests.session()
HEADERS = { 'origin': 'https://example.com',
                    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
                    'referer': 'https://example.com/login.php',
                    'cookie': 'PHPSESSID=gke5ufo97q0te7ktrkeul70ti7; 'flog=6'; 'ufp=9tedcd5c579826fr2fe850acb9831088',
}

data = { 'username': username,
             'password': password,
             'do': 'login',
             'language': 'en'
}

url = url_constructor("login.php?type=login")
response = s.post(url, headers=HEADERS, data=data)


I got these cookies when converting a curl (bash) to python-requests, but if for example I make a request to the web either through the post or get method and I try to get the header or the cookies, I only get 'flog=6' cookie, and the others do not show them to me.

I understand that using sessions is supposed to work but if I don't add cookies, it's as if I didn't log in. Any help will be appreciated!
Reply

Logout Mark Read Team Forum Stats Members Help
How can all cookies be added automatically to the header? using requests0