-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathweb.py
More file actions
29 lines (25 loc) · 828 Bytes
/
web.py
File metadata and controls
29 lines (25 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# coding=utf-8
from chinaapi.web import ClientBase
from chinaapi.exceptions import ApiResponseError
from hashlib import md5
import time
ERROR = {
'error3': '用户名或密码错误',
}
class Client(ClientBase):
def login(self, username, password):
password = md5(password).hexdigest().lower()
data = dict(userid=username,
password=password,
appid=9999,
persistentcookie=1,
s=time.time(),
b=7,
w=1440,
pwdtype=1,
v=26,
)
r = self._session.post('https://passport.sohu.com/sso/login.jsp', data=data)
if 'success' not in r.content:
raise ApiResponseError(r, 0, r.content.replace('\n', ''))
return r