搜尋
首頁後端開發Python教學利用打码兔和超人打码自封装的打码类分享

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

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
python中兩個列表的串聯替代方案是什麼?python中兩個列表的串聯替代方案是什麼?May 09, 2025 am 12:16 AM

可以使用多種方法在Python中連接兩個列表:1.使用 操作符,簡單但在大列表中效率低;2.使用extend方法,效率高但會修改原列表;3.使用 =操作符,兼具效率和可讀性;4.使用itertools.chain函數,內存效率高但需額外導入;5.使用列表解析,優雅但可能過於復雜。選擇方法應根據代碼上下文和需求。

Python:合併兩個列表的有效方法Python:合併兩個列表的有效方法May 09, 2025 am 12:15 AM

有多種方法可以合併Python列表:1.使用 操作符,簡單但對大列表不內存高效;2.使用extend方法,內存高效但會修改原列表;3.使用itertools.chain,適用於大數據集;4.使用*操作符,一行代碼合併小到中型列表;5.使用numpy.concatenate,適用於大數據集和性能要求高的場景;6.使用append方法,適用於小列表但效率低。選擇方法時需考慮列表大小和應用場景。

編譯的與解釋的語言:優點和缺點編譯的與解釋的語言:優點和缺點May 09, 2025 am 12:06 AM

CompiledLanguagesOffersPeedAndSecurity,而interneterpretledlanguages provideeaseafuseanDoctability.1)commiledlanguageslikec arefasterandSecureButhOnderDevevelmendeclementCyclesclesclesclesclesclesclesclesclesclesclesclesclesclesclesclesclesclesandentency.2)cransportedeplatectentysenty

Python:對於循環,最完整的指南Python:對於循環,最完整的指南May 09, 2025 am 12:05 AM

Python中,for循環用於遍歷可迭代對象,while循環用於條件滿足時重複執行操作。 1)for循環示例:遍歷列表並打印元素。 2)while循環示例:猜數字遊戲,直到猜對為止。掌握循環原理和優化技巧可提高代碼效率和可靠性。

python concatenate列表到一個字符串中python concatenate列表到一個字符串中May 09, 2025 am 12:02 AM

要將列表連接成字符串,Python中使用join()方法是最佳選擇。 1)使用join()方法將列表元素連接成字符串,如''.join(my_list)。 2)對於包含數字的列表,先用map(str,numbers)轉換為字符串再連接。 3)可以使用生成器表達式進行複雜格式化,如','.join(f'({fruit})'forfruitinfruits)。 4)處理混合數據類型時,使用map(str,mixed_list)確保所有元素可轉換為字符串。 5)對於大型列表,使用''.join(large_li

Python的混合方法:編譯和解釋合併Python的混合方法:編譯和解釋合併May 08, 2025 am 12:16 AM

pythonuseshybridapprace,ComminingCompilationTobyTecoDeAndInterpretation.1)codeiscompiledtoplatform-Indepententbybytecode.2)bytecodeisisterpretedbybythepbybythepythonvirtualmachine,增強效率和通用性。

了解python的' for”和' then”循環之間的差異了解python的' for”和' then”循環之間的差異May 08, 2025 am 12:11 AM

theKeyDifferencesBetnewpython's“ for”和“ for”和“ loopsare:1)” for“ loopsareIdealForiteringSequenceSquencesSorkNowniterations,而2)”,而“ loopsareBetterforConterContinuingUntilacTientInditionIntionismetismetistismetistwithOutpredefinedInedIterations.un

Python串聯列表與重複Python串聯列表與重複May 08, 2025 am 12:09 AM

在Python中,可以通過多種方法連接列表並管理重複元素:1)使用 運算符或extend()方法可以保留所有重複元素;2)轉換為集合再轉回列表可以去除所有重複元素,但會丟失原有順序;3)使用循環或列表推導式結合集合可以去除重複元素並保持原有順序。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具