You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12306/damatuCode/ruokuai.py

57 lines
1.5 KiB

# coding:utf-8
import requests
from hashlib import md5
class RClient(object):
def __init__(self, username, password):
self.username = username
self.password = md5(password).hexdigest()
self.soft_id = '96061'
self.soft_key = '6facb9da7bb645ad9c4a229464b2cf89'
self.base_params = {
'username': self.username,
'password': self.password,
'softid': self.soft_id,
'softkey': self.soft_key,
}
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)
6 years ago
print(r)
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__':
7 years ago
rc = RClient('931128603', '',)
im = open('tkcode', 'rb').read()
print rc.rk_create(im, 6113)