1. 程式人生 > >爬蟲------github登入

爬蟲------github登入

爬蟲------github登入

import requests
from bs4 import BeautifulSoup

r1 = requests.get(
    url='https://github.com/login'
)
s1 = BeautifulSoup(r1.text,'html.parser')
token = s1.find(name='input',attrs={'name':'authenticity_token'}).get('value')
r1_cookie_dict = r1.cookies.get_dict()

r2 = requests.
post( url='https://github.com/session', data={ 'commit':'Sign in', 'utf8':'✓', 'authenticity_token':token, 'login':'[email protected]', 'password':'sdfasdfasdfasdf' }, cookies=r1_cookie_dict ) r2_cookie_dict = r2.cookies.get_dict() r3 = requests.
get( url='https://github.com/settings/emails', cookies=r2_cookie_dict ) print(r3.text)