MCPcopy Create free account
hub / github.com/ZiniuLu/Python-100-Days / main

Function main

Day66-75/code/example08.py:5–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4
5def 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
27if __name__ == '__main__':

Callers 1

example08.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected