| 3 | |
| 4 | |
| 5 | def main(): |
| 6 | resp = requests.get('https://github.com/login') |
| 7 | if resp.status_code != 200: |
| 8 | return |
| 9 | cookies = resp.cookies.get_dict() |
| 10 | print(cookies) |
| 11 | soup = BeautifulSoup(resp.text, 'lxml') |
| 12 | utf8_value = \ |
| 13 | soup.select_one('form input[name=utf8]').attrs['value'] |
| 14 | authenticity_token_value = \ |
| 15 | soup.select_one('form input[name=authenticity_token]').attrs['value'] |
| 16 | data = { |
| 17 | 'utf8': utf8_value, |
| 18 | 'authenticity_token': authenticity_token_value, |
| 19 | 'login': 'jackfrued@gmail.com', |
| 20 | 'password': 'yourpassword' |
| 21 | } |
| 22 | resp = requests.post('https://github.com/session', |
| 23 | data=data, cookies=cookies) |
| 24 | print(resp.text) |
| 25 | |
| 26 | |
| 27 | if __name__ == '__main__': |