mardi 30 juillet 2019

Can't login to a website with python request

I'm trying to log to a website https://app.factomos.com/connexion but that doesn't work, I still have the error 403, I try with different headers and different data, but I really don't know where is the problem...

I try another way with MechanicalSoup but that still return to the connection page.

If someone can help me... Thank you for your time :/

import requests
from bs4 import BeautifulSoup as bs

url = 'https://factomos.com'
email = 'myemail'
password = 'mypassword'
url_login = 'https://factomos.com/connexion'

headers = requests.utils.default_headers()
headers.update({
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36',
})

data_login = {
    'appAction': 'login',
    'email': email,
    'password': password
}

with requests.Session() as s:
    dash = s.post(url_login, headers=headers, data=data_login)
    print(dash.status_code)


# MechanicalSoup
import mechanicalsoup
browser = mechanicalsoup.StatefulBrowser()
resp = browser.open("https://app.factomos.com/connexion")
browser.select_form('form[id="login-form"]')
browser["email"] = 'myemail'
browser["password"] = 'mypassword'
response = browser.submit_selected()
print("submite: ", response.status_code)
print(browser.get_current_page())

I expect a response 200 with the dashboard page but the actual response is 403 or the connection page.




Aucun commentaire:

Enregistrer un commentaire