Behdad Ahmadi Behdad Ahmadi - 1 year ago 178
Python Question

Login to in python

I want to login to in python. I dont want to use mechanize, twill or anything like that. I want to only use requests or urllib.

This is my code that I use to login but failed:

import requests
login_url = ''
payload = {'email':'EMAIL','pass':'PASSWORD'}
result = requests.get(login_url,data=payload).content

I also try with this payload:

payload = {'role':'al_frame','expire':'1','captcha_sid':'','captcha_key':'','_origin':'','ip_h':'1bab73f98c2a0d4319','lg_h':'b2765a98e04fead77c','email':'EMAIL','pass':'PASSWORD'}

But both of them failed to login to . How can I login to the website?

Answer Source

After some hours working on it, at the end I found the solutions for it.

import requests
from bs4 import BeautifulSoup as bs
,'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0'}
payload = {'email':'YOUR EMAIL','pass':'PASSWORD'}

with requests.Session() as S:
    page = S.get('')
    soup = bs(page.content,'lxml')
    url = soup.find('form')['action']
    p =,data=payload,headers=headers)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download