当前位置:   article > 正文

云打码案例 python_云码打码案例分析怎么写

云码打码案例分析怎么写

1.云打码 http://www.yundama.com/   下载 YDMHTTPDemo3.x(python3)

2.将文件解压至项目目录下 命名如yzm_util.py

3.注册云打码平台,普通用户和开发者用户各一个,在开发者用户下增加我的新软件,得到软件代码和通讯密匙,在yzm_util.py中修改相应代码

4. 将yzm_util.py post_url()方法后修改内容如下:

  1. ######################################################################
  2. def get_code(filename):
  3. # 普通用户名
  4. username = 'xxxx'
  5. # 普通用户密码
  6. password = 'xxxx'
  7. # 软件ID,开发者分成必要参数。登录开发者后台【我的软件】获得!
  8. appid = xxxx
  9. # 软件密钥,开发者分成必要参数。登录开发者后台【我的软件】获得!
  10. appkey = 'xxxx'
  11. # 图片文件
  12. filename = filename
  13. # 验证码类型,# 例:1004表示4位字母数字,不同类型收费不同。请准确填写,否则影响识别率。在此查询所有类型 http://www.yundama.com/price.html
  14. codetype = 1005
  15. # 超时时间,秒
  16. timeout = 60
  17. # 检查
  18. if (username == 'username'):
  19. print('请设置好相关参数再测试')
  20. else:
  21. # 初始化
  22. yundama = YDMHttp(username, password, appid, appkey)
  23. # 登陆云打码
  24. uid = yundama.login();
  25. # print('uid: %s' % uid)
  26. # 查询余额
  27. balance = yundama.balance();
  28. # print('balance: %s' % balance)
  29. # 开始识别,图片路径,验证码类型ID,超时时间(秒),识别结果
  30. cid, result = yundama.decode(filename, codetype, timeout);
  31. # print('cid: %s, result: %s' % (cid, result))
  32. return result
  33. ######################################################################

代码:

  1. # -*- coding: utf-8 -*-
  2. # @Time : 2020/4/20 18:59
  3. # @Author : Oneqq
  4. # @File : 26.云打码使用案例.py
  5. # @Software: PyCharm
  6. import requests
  7. from fake_useragent import UserAgent
  8. from Pratice1.yzm_util import get_code
  9. def get_img():
  10. img_url = "http://www.yundama.com/index/captcha"
  11. response = session.get(img_url, headers=headers)
  12. with open('yzm.jpg', 'wb') as f:
  13. f.write(response.content)
  14. code = get_code('yzm.jpg')
  15. print(code)
  16. return code
  17. def do_login(code):
  18. login_url = "http://www.yundama.com/index/login"
  19. params = {
  20. "username": "xxxx",
  21. "password": "xxxx",
  22. "utype": "1",
  23. "vcode": code
  24. }
  25. response = session.get(login_url, headers=headers, params=params)
  26. print(response.text)
  27. if __name__ == '__main__':
  28. index_url = "http://www.yundama.com/"
  29. headers = {
  30. "User-Agent": UserAgent().chrome
  31. }
  32. session = requests.Session()
  33. response = session.get(index_url, headers=headers)
  34. code = get_img()
  35. do_login(code)

结果:登录成功

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/287391
推荐阅读
相关标签
  

闽ICP备14008679号