The use of coding rabbit and Superman to play the Code of self-styled to share the code class

Source: Internet
Author: User
Self-packaged coding class, under Windows recommended coding Rabbit (call the official DLL), Linux recommended Superman code (HTTP API)

Copy the Code code as follows:


# Coding:utf-8
From ctypes Import *
Import requests
Import JSON
Import Random
Import Binascii
From config import config

Class Dama2 ():
"" The Code of the Rabbit dozen yards. "" "
_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 ') # recognition error
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 () # Default

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 replacement for their own
"""

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.