import requests
from bs4 import BeautifulSoup
LOGIN = ''
PASSWORD = ''
login_page = 'https://github.com/login'
auth_page = 'https://github.com/session'
headers = {'User-Agent': 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0'}
payload = {'login': LOGIN,
'password': PASSWORD,
'authenticity_token': '',
'commit': 'Sign in',
'utf8': '✓'}
with requests.Session() as session:
s = session.get(login_page, headers=headers)
soup = BeautifulSoup(s.text, 'html.parser')
auth_token = soup.find('input', attrs={'name': 'authenticity_token'})
payload['authenticity_token'] = auth_token['value']
s = session.post(auth_page, data=payload, headers=headers)
print(s.text)
Вам правильно сказали, используйте API. Пример есть даже на главной странице к
requests.