日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Python学习--打码平台

發布時間:2023/12/13 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 Python学习--打码平台 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

打碼平臺介紹

作用:可以通過第三方平臺進行智能識別或者人工識別圖片。

優點:1. 價格便宜; 2. 使用簡單; 3. 識別率高

平臺介紹:

- 云打碼(推薦) [http://www.yundama.com/]

- 極驗驗證碼智能識別輔助 [http://jiyandoc.c2567.com/]

- 超級鷹
- 打碼兔
- 若快打碼
- 等等

流程圖:

云打碼需要注冊開發者賬號和用戶賬號,注冊地址:[http://www.yundama.com/]

開發者賬號用于,下載DEMO,調試自己的軟件

用戶賬號用于登錄,充值,平臺是收費的(1元=1000分)

【開發者】

添加我的軟件,獲取通信秘鑰

查看驗證碼類型:

http://www.yundama.com/price.html

題分價格:

【用戶】

充值

12306的驗證碼Demo

import http.client, mimetypes, urllib, json, time, requests


######################################################################

class YDMHttp:
    apiurl = 'http://api.yundama.com/api.php'
    username = ''
    password = ''
    appid = ''
    appkey = ''

    def __init__(self, username, password, appid, appkey):
        self.username = username
        self.password = password
        self.appid = str(appid)
        self.appkey = appkey

    def request(self, fields, files=[]):
        response = self.post_url(self.apiurl, fields, files)
        response = json.loads(response)
        return response

    def balance(self):
        data = {'method': 'balance', 'username': self.username, 'password': self.password, 'appid': self.appid,
                'appkey': self.appkey}
        response = self.request(data)
        if (response):
            if (response['ret'] and response['ret'] < 0):
                return response['ret']
            else:
                return response['balance']
        else:
            return -9001

    def login(self):
        data = {'method': 'login', 'username': self.username, 'password': self.password, 'appid': self.appid,
                'appkey': self.appkey}
        response = self.request(data)
        if (response):
            if (response['ret'] and response['ret'] < 0):
                return response['ret']
            else:
                return response['uid']
        else:
            return -9001

    def upload(self, filename, codetype, timeout):
        data = {'method': 'upload', 'username': self.username, 'password': self.password, 'appid': self.appid,
                'appkey': self.appkey, 'codetype': str(codetype), 'timeout': str(timeout)}
        file = {'file': filename}
        response = self.request(data, file)
        if (response):
            if (response['ret'] and response['ret'] < 0):
                return response['ret']
            else:
                return response['cid']
        else:
            return -9001

    def result(self, cid):
        data = {'method': 'result', 'username': self.username, 'password': self.password, 'appid': self.appid,
                'appkey': self.appkey, 'cid': str(cid)}
        response = self.request(data)
        return response and response['text'] or ''

    def decode(self, filename, codetype, timeout):
        cid = self.upload(filename, codetype, timeout)
        if (cid > 0):
            for i in range(0, timeout):
                result = self.result(cid)
                if (result != ''):
                    return cid, result
                else:
                    time.sleep(1)
            return -3003, ''
        else:
            return cid, ''

    def report(self, cid):
        data = {'method': 'report', 'username': self.username, 'password': self.password, 'appid': self.appid,
                'appkey': self.appkey, 'cid': str(cid), 'flag': '0'}
        response = self.request(data)
        if (response):
            return response['ret']
        else:
            return -9001

    def post_url(self, url, fields, files=[]):
        for key in files:
            files[key] = open(files[key], 'rb');
        res = requests.post(url, files=files, data=fields)
        return res.text


######################################################################
# 用戶名
username = 'username '

# 密碼
password = 'password'

# 軟件ID,開發者分成必要參數。登錄開發者后臺【我的軟件】獲得!
appid = 6795

# 軟件密鑰,開發者分成必要參數。登錄開發者后臺【我的軟件】獲得!
appkey = '62a672323232323218be141d9a77463c5'

# 圖片文件,上傳12306的圖片
filename = 'dignshuji.jpg'

# 驗證碼類型,# 例:1004表示4位字母數字,不同類型收費不同。請準確填寫,否則影響識別率。
# 在此查詢所有類型 http://www.yundama.com/price.html
# 12306的驗證碼類型是6701
codetype = 6701

# 超時時間,秒
timeout = 60

# 檢查
if (username == 'username'):
    print('請設置好相關參數再測試')
else:
    # 初始化
    yundama = YDMHttp(username, password, appid, appkey)

    # 登陸云打碼
    uid = yundama.login();
    print('uid: %s' % uid)

    # 查詢余額
    balance = yundama.balance();
    print('balance: %s' % balance)

    # 開始識別,圖片路徑,驗證碼類型ID,超時時間(秒),識別結果
    cid, result = yundama.decode(filename, codetype, timeout);
    print('cid: %s, result: %s' % (cid, result))

######################################################################

12306圖片

返回結果表示: 第2,7,8張圖是訂書機

總結

以上是生活随笔為你收集整理的Python学习--打码平台的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。