I am creating a script that logs onto Discord by using a token.
This is my code:
import requests
headers = {
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
}
with requests.Session() as s:
url = 'https://discord.com/login'
r = s.get(url, headers=headers)
print(r.content)
In order to actually login using a token I need to run the following code in the browser's developer console:
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
}
login ("[enter your token here]")
I know that this is possible in selenium but I really need to do it in requests.