自封装的打码类, windows下建议用打码兔(调用的官方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 = ''
_password = ''
__attrs__ = ['DM', 'username', 'password', 'softuuid', 'timeout']
def __init__(self):
self.DM = WinDLL('lib/CrackCaptchaAPI.dll')
if not self._username:
Dama2._username = config['dama']['dama2']['username']
Dama2._password = config['dama']['dama2']['password']
self.username = c_char_p(self._username)
self.password = c_char_p(self._password)
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.password, imgdata, imgleng, self.timeout, imgtype, res)
if code > 0:
return res.value
return False
def report_err(self, imgid):
return False
class Chaoren():
_username = ''
_password = ''
__attrs__ = ['DM', 'username', 'password', 'softuuid', 'timeout']
def __init__(self):
if not self._username:
Chaoren._username = config['dama']['chaoren']['username']
Chaoren._password = config['dama']['chaoren']['password']
self.s = requests.Session()
self.s.encoding = 'utf-8'
self.s.timeout = 16
self.data = {
'username': self.username,
'password': self.password,
'softid': '1234',#1234换成自己的
'imgid': '',
'imgdata': ''
}
def get_left_point(self):
try:
r = self.s.post('http://apib.sz789.net: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.net: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.net: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.w = Dama2()
elif self.flag == 'chaoren':
self.w = Chaoren()
else:
self.w = Dama2() # 默认
def recv_byte(self, imgdata):
return self.w.recv_byte(imgdata)
def report_err(self, imgid):
return self.w.report_err(imgid)
# test
if __name__ == '__main__':
pass
"""
username and password 更换为自己的
"""
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]