欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

利用打码兔和超人打码自封装的打码类分享

程序员文章站 2022-12-28 13:31:30
自封装的打码类, windows下建议用打码兔(调用的官方dll),linux下建议超人打码(http api) 复制代码 代码如下:# coding:utf-8fro...

自封装的打码类, 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 更换为自己的
"""