Skip to content

Instantly share code, notes, and snippets.

@SakuraSa
Created September 23, 2014 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SakuraSa/3f1095cb0e98e6a0c59c to your computer and use it in GitHub Desktop.
Save SakuraSa/3f1095cb0e98e6a0c59c to your computer and use it in GitHub Desktop.
can_it_works?
from requests import session
from bs4 import BeautifulSoup as bs
USER = 'USER'
PASSWORD = 'PASSWORD'
URL1 = 'https://github.com/login'
URL2 = 'https://github.com/session'
with session() as s:
req = s.get(URL1).text
html = bs(req)
token = html.find("input", {"name": "authenticity_token"}).attrs['value']
com_val = html.find("input", {"name": "commit"}).attrs['value']
login_data = {'login': USER,
'password': PASSWORD,
'commit' : 'Sign in',
'authenticity_token' : token}
r1 = s.post(URL2, data = login_data)
for c in s.cookies:
print c
print '-' * 20
print 'logged_in:',s.cookies['logged_in']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment