lundi 2 septembre 2019

I can't login to website using python-requests

Is this the right way to login with post method to a website :

headers = {
    "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
    "Accept-Encoding" : "gzip, deflate",
    "Accept-Language" : "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,ar;q=0.6",
    "Content-Type" : "application/x-www-form-urlencoded",
    "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
}

login_data = {
    "WD_BUTTON_CLICK_" : "A34",
    "A6" : "USERNAME",
    "A17" : "PASS",
    "A2" : "2",
    "A2_PUCES" : "1",
    }

with requests.Session() as s:
    s.headers = headers
    url = "http://213.179.182.112/EGC360"
    r = s.post(url , headers = headers , data = login_data)    
    soup = BeautifulSoup(r.content , 'html.parser')

i get <Response [200]> as response to my post.

When i print the content i get the content for the index page (first page), i'm new in web scraping, hope you can help me to do this




Aucun commentaire:

Enregistrer un commentaire