M
M
Mishele1232021-11-09 16:40:17
Python
Mishele123, 2021-11-09 16:40:17

How to log in to the site through cookies?

In short, there is a log file. There are a lot of different cookie values. I need to login to roblox account using this link https://auth.roblox.com/v2/login . How to do it. I know to use the requests library. But how do I open a cookie file and pull out data from there and how do I log in to my account. (I would be glad if you tell me in detail!)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Golovanenko, 2021-11-09
@drygdryg

Divide the task into 2 subtasks:
1) parse a text log file and extract cookies from it into a "key-value" dictionary;
2) use cookies for authorization.
Regular expressions (module re) can help you find the right cookie lines in the log. Please post the log file format here if possible so I can give you more specific advice.
To use cookies in requests, create a session and set the cookie dictionary to it:

import requests

http = requests.Session()
my_cookies = {'Abc': '123', 'Def': '456'}
http.cookies.update(my_cookies)

After that, you can, for example, make GET and POST requests using the http session instance:
r = http.post('https://auth.roblox.com/v2/login', ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question