利用打码兔和超人打码自封装的打码类分享
自封装的打码类, indos下建议用打码兔(调用的官方dll),linux下建议超人打码(http api)
复制代码 代码如下:
# coding:utf-8
from ctypes import
import requests
import json
import random
import binascii
from config import config
class Dama2():
"""打码兔打码."""
_username = ''
_passord = ''
__attrs__ = ['DM', 'username', 'passord', 'softuuid', 'timeout']
def __init__(self):
self.DM = WinDLL('lib/CrackCaptchaAPI.dll')
if not self._username:
Dama2._username = config['dama']['dama2']['username']
Dama2._passord = config['dama']['dama2']['passord']
self.username = c_char_p(self._username)
self.passord = c_char_p(self._passord)
self.softuuid = c_char_p('6fbc06efdc777eee854842572102daec')
self.timeout = c_ushort(30)
def recv_byte(self, imgdata, imgtype=42):
# imgdata = c_void_p(imgdata)
imgleng = c_uint(len(imgdata))
imgtype = c_ulong(imgtype)
res = c_char_p('')
code = self.DM.D2Buf(self.softuuid, self.username, self.passord, imgdata, imgleng, self.timeout, imgtype, res)
if code > 0:
return res.value
return False
def report_err(self, imgid):
return False
class Chaoren():
_username = ''
_passord = ''
__attrs__ = ['DM', 'username', 'passord', 'softuuid', 'timeout']
def __init__(self):
if not self._username:
Chaoren._username = config['dama']['chaoren']['username']
Chaoren._passord = config['dama']['chaoren']['passord']
self.s = requests.Session()
self.s.encoding = 'utf-8'
self.s.timeout = 16
self.data = {
'username': self.username,
'passord': self.passord,
'softid': '1234',#1234换成自己的
'imgid': '',
'imgdata': ''
}
def get_left_point(self):
try:
r = self.s.post('http://apib.sz789.:88/GetUserInfo.ashx', self.data)
return r.json()
except requests.ConnectionError:
return self.get_left_point()
except:
return False
def recv_byte(self, imgdata):
self.data['imgdata'] = binascii.b2a_hex(imgdata).upper()
try:
r = self.s.post('http://apib.sz789.:88/RecvByte.ashx', self.data)
res = r.json()
if res[u'info'] == -1:
self.report_err(res[u'imgid']) # 识别错误
return False
return r.json()[u'result']
except requests.ConnectionError:
return self.recv_byte(imgdata)
except:
return False
def report_err(self, imgid):
self.data['imgid'] = imgid
if self.data['imgdata']:
del self.data['imgdata']
try:
r = self.s.post('http://apib.sz789.:88/ReportError.ashx', self.data)
return r.json()
except requests.ConnectionError:
return self.report_err(imgid)
except:
return False
class Dama():
flag = 'dama2'
def __init__(self):
if self.flag == 'dama2':
self. = Dama2()
elif self.flag == 'chaoren':
self. = Chaoren()
else:
self. = Dama2() # 默认
def recv_byte(self, imgdata):
return self..recv_byte(imgdata)
def report_err(self, imgid):
return self..report_err(imgid)
# test
if __name__ == '__main__':
pass
"""
username and passord 更换为自己的
"""
空调维修
- 海信电视维修站 海信电视维修站点
- 格兰仕空调售后电话 格兰仕空调维修售后服务电
- 家电售后服务 家电售后服务流程
- 华扬太阳能维修 华扬太阳能维修收费标准表
- 三菱电机空调维修 三菱电机空调维修费用高吗
- 美的燃气灶维修 美的燃气灶维修收费标准明细
- 科龙空调售后服务 科龙空调售后服务网点
- 华帝热水器维修 华帝热水器维修常见故障
- 康泉热水器维修 康泉热水器维修故障
- 华凌冰箱维修电话 华凌冰箱维修点电话
- 海尔维修站 海尔维修站点地址在哪里
- 北京海信空调维修 北京海信空调售后服务
- 科龙空调维修 科龙空调维修故障
- 皇明太阳能售后 皇明太阳能售后维修点
- 海信冰箱售后服务 海信冰箱售后服务热线电话
- 海尔热水器服务热线