-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.py
24 lines (21 loc) · 813 Bytes
/
login.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
class DouBan:
def __init__(self):
self.login_url = 'https://accounts.douban.com/j/mobile/login/basic'
self.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
}
self.login_data = {
'ck': '',
'remember': 'false',
'name': '13388958463',
'password': 'cm000610'
}
self.session = requests.Session()
self.get_html(self.login_url)
self.login()
def login(self):
response = self.session.post(self.login_url, data=self.login_data, headers=self.headers)
print(response.json())
def get_html(self, url):
return self.session.get(url, headers = self.headers)