forked from zhangkai3110/JD_AutoSubmit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rk.py
executable file
·57 lines (48 loc) · 1.55 KB
/
rk.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# coding:utf-8
import requests
from hashlib import md5
class RClient(object):
def __init__(self, username, password):
self.username = username
self.password = md5(password.encode('utf-8')).hexdigest()
self.soft_id = '80032'
self.soft_key = '8c37f5b5c5784e2ebe7681f4ff325cee'
self.base_params = {
'username': self.username,
'password': self.password,
'softid': '80032',
'softkey': '8c37f5b5c5784e2ebe7681f4ff325cee',
}
self.headers = {
'Connection': 'Keep-Alive',
'Expect': '100-continue',
'User-Agent': 'ben',
}
def rk_create(self, im, im_type, timeout=60):
"""
im: 图片字节
im_type: 题目类型
"""
params = {
'typeid': im_type,
'timeout': timeout,
}
params.update(self.base_params)
files = {'image': ('a.jpg', im)}
r = requests.post('http://api.ruokuai.com/create.json', data=params, files=files, headers=self.headers)
return r.json()
def rk_report_error(self, im_id):
"""
im_id:报错题目的ID
"""
params = {
'id': im_id,
}
params.update(self.base_params)
r = requests.post('http://api.ruokuai.com/reporterror.json', data=params, headers=self.headers)
return r.json()
if __name__ == '__main__':
rc = RClient('username', 'password')
im = open('a.jpg', 'rb').read()
print (rc.rk_create(im, 3040))