· 6 years ago · Jan 10, 2020, 11:36 AM
1from bs4 import BeautifulSoup as Soup
2import requests
3headers = {
4 'user-agent' : 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.18.2924.87 Safari/537.36'
5}
6login_data = {
7 'authenticity_token' : '****',
8 'user[email]' : "*****@gmail.com",
9 'user[password]' : "*****",
10 'commit': 'Se connecter',
11}
12my_url = 'https://candidature.1337.ma/meetings/'
13
14with requests.session() as s:
15 url = "https://candidature.1337.ma/users/sign_in/"
16 r = s.get(url, headers=headers)
17 soup = Soup(r.content, 'html5lib')
18 login_data['authenticity_token'] = soup.find('input', attrs={'name': 'authenticity_token'})['value']
19 r = s.post(url, data=login_data, headers=headers)
20 print(r.text)