利用打碼兔和超人打碼自封裝的打碼類分享
自封裝的打碼類, windows下建議用打碼兔(調(diào)用的官方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']) # 識(shí)別錯(cuò)誤
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() # 默認(rèn)
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 更換為自己的
"""
相關(guān)文章
Python正則表達(dá)式如何進(jìn)行字符串替換實(shí)例
Python正則表達(dá)式在使用中會(huì)經(jīng)常應(yīng)用到字符串替換的代碼。這篇文章主要介紹了Python正則表達(dá)式如何進(jìn)行字符串替換,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2016-12-12
python中的計(jì)時(shí)器timeit的使用方法
本篇文章主要介紹了python中的計(jì)時(shí)器timeit的使用方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2017-10-10
python實(shí)現(xiàn)圖像處理之PiL依賴庫(kù)的案例應(yīng)用詳解
這篇文章主要介紹了python實(shí)現(xiàn)圖像處理之PiL依賴庫(kù)的案例應(yīng)用詳解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07
Python產(chǎn)生batch數(shù)據(jù)的操作
這篇文章主要介紹了Python產(chǎn)生batch數(shù)據(jù)的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2021-03-03
python GUI庫(kù)圖形界面開發(fā)之PyQt5控件數(shù)據(jù)拖曳Drag與Drop詳細(xì)使用方法與實(shí)例
這篇文章主要介紹了python GUI庫(kù)圖形界面開發(fā)之PyQt5控件數(shù)據(jù)拖曳Drag與Drop詳細(xì)使用方法與實(shí)例,需要的朋友可以參考下2020-02-02
python機(jī)器學(xué)習(xí)使數(shù)據(jù)更鮮活的可視化工具Pandas_Alive
今天我分享大家一款非常棒的動(dòng)畫可視化工具:Pandas_Alive,它以?matplotlib?繪圖為后端,不僅可以創(chuàng)建出令人驚嘆的動(dòng)畫可視化,而且使用方法非常簡(jiǎn)單。本文詳情如下2021-11-11
python實(shí)現(xiàn)實(shí)時(shí)視頻流播放代碼實(shí)例
這篇文章主要介紹了python實(shí)現(xiàn)實(shí)時(shí)視頻流播放代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-01-01
python統(tǒng)計(jì)RGB圖片某像素的個(gè)數(shù)案例
這篇文章主要介紹了python統(tǒng)計(jì)RGB圖片某像素的個(gè)數(shù)案例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2021-03-03

