python手工打码_Python学习--打码平台

打码平台介绍

作用:可以通过第三方平台进行智能识别或者人工识别图片。

优点:1. 价格便宜; 2. 使用简单; 3. 识别率高

平台介绍:

- 极验验证码智能识别辅助 [http://jiyandoc.c2567.com/]

- 超级鹰

- 打码兔

- 若快打码

- 等等

流程图:

云打码需要注册开发者账号和用户账号,注册地址:[http://www.yundama.com/]

开发者账号用于,下载DEMO,调试自己的软件

用户账号用于登录,充值,平台是收费的(1元=1000分)

【开发者】

添加我的软件,获取通信秘钥

查看验证码类型:

题分价格:

【用户】

充值

12306的验证码Demoimport 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张图是订书机

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值