验证码(抠图)和超级鹰的使用

  1. 获取验证码

    from selenium.webdriver import Chrome, ChromeOptions
    import time
    from chaojiying import ChaojiyingClient# 使用PIL前需要安装:pillow
    from PIL import Imageoptions = ChromeOptions()
    # 设置取消测试环境
    options.add_experimental_option('excludeSwitches', ['enable-automation'])
    b = Chrome(options=options)def get_data():url = 'https://passport.bi***i.com/'b.get(url)# print(b.page_source)time.sleep(1)# 用户名username = b.find_element_by_css_selector('#login-username')# 密码pw = b.find_element_by_css_selector('#login-passwd')# 输入用户名和密码username.send_keys('1392302')pw.send_keys('123456')# 获取登录按钮login_btn = b.find_element_by_css_selector('.btn.btn-login')# 点击登录按钮login_btn.click()time.sleep(1)# 获取验证码盒子code_div = b.find_element_by_css_selector('.geetest_panel_next')location = code_div.locationsize = code_div.sizex, y = location['x'], location['y']w, h = size['width'], size['height']# 截屏screen_data = b.get_screenshot_as_png()print(type(screen_data))open('files/c.png', 'wb').write(screen_data)# 抠图# a.获取原图image_data = Image.open('files/c.png')# image_data.show()# b.剪切code_data = image_data.crop((x*2, y*2, x*2+w*2, y*2+h*2))# code_data.show()# 保存验证码图片code_data.save('files/d.png')# 调用超级鹰 获取验证码信息# cjy = ChaojiyingClient('用户账号', '用户密码', '后台参数')# result = cjy.post_pic(需要识别验证码的图片的地址, 9004)# print(result)# time.sleep(10)if __name__ == '__main__':get_data()
    
  2. 滑动滑块

    from selenium.webdriver import Chrome, ChromeOptions, ActionChains
    import time
    from PIL import Image
    import io
    from chaojiying import ChaojiyingClient# bytes  -> (只读)字节流  ->  BytesIO(读写)字节流
    cjy = ChaojiyingClient('yuting', '123456', '915035')def get_data():options = ChromeOptions()# 设置取消测试环境options.add_experimental_option('excludeSwitches', ['enable-automation'])b = Chrome(options=options)b.get('https://passport.******.cm')btn = b.find_element_by_css_selector('.login-tab.login-tab-r')btn.click()time.sleep(1)name = b.find_element_by_css_selector('#loginname')pw = b.find_element_by_css_selector('#nloginpwd')name.send_keys('账号')pw.send_keys('密码')login_btn = b.find_element_by_css_selector('#loginsubmit')login_btn.click()# 获取验证码的位置和大小code_dive = b.find_element_by_css_selector('.JDJRV-bigimg')location = code_dive.locationsize = code_dive.sizex, y = location['x'], location['y']w, h = size['width'], size['height']# 截屏screen_data = b.get_screenshot_as_png()open('files/screen.png', 'wb').write(screen_data)# 抠图image = Image.open('files/screen.png')code_image = image.crop((x*2, y*2, x*2 + w*2, y*2 + h*2))# code_image.thumbnail((w, h))code_image.save('files/code.png')time.sleep(1)# 获取验证坐标pic_data = open('files/code.png', 'rb').read()result = cjy.post_pic(pic_data, 9101)print(result)code_x, code_y = result['pic_str'].split(',')code_x = int(code_x)# 滑动滑块slider = b.find_element_by_css_selector('.JDJRV-slide-inner.JDJRV-slide-btn')action = ActionChains(b)count = code_x//2//10# 一步到位的拖拽# drag_and_drop_by_offset(拖拽目标标签, 在x方向的位移, 在y方向的位移)# action.drag_and_drop_by_offset(slider, int(code_x)//2, 0)# action.release(slider)# action.perform()   # 执行动作# 一点一点的拖拽action.click_and_hold(slider)for x in range(count):action.move_by_offset(10, 0)time.sleep(0.5)action.release(slider)action.perform()time.sleep(10)get_data()
    
  3. 超级鹰(py文件)

    import requests
    from hashlib import md5class ChaojiyingClient(object):def __init__(self, username, password, soft_id):self.username = usernamepassword =  password.encode('utf8')self.password = md5(password).hexdigest()self.soft_id = soft_idself.base_params = {'user': self.username,'pass2': self.password,'softid': self.soft_id,}self.headers = {'Connection': 'Keep-Alive','User-Agent': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',}def post_pic(self, im, codetype):"""im: 图片字节codetype: 题目类型 参考 http://www.chaojiying.com/price.html"""params = {'codetype': codetype,}params.update(self.base_params)files = {'userfile': ('ccc.jpg', im)}r = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=params, files=files, headers=self.headers)return r.json()def report_error(self, im_id):"""im_id:报错题目的图片ID"""params = {'id': im_id,}params.update(self.base_params)r = requests.post('http://upload.chaojiying.net/Upload/ReportError.php', data=params, headers=self.headers)return r.json()if __name__ == '__main__':# 1.创建超级鹰对象chaojiying = ChaojiyingClient('用户账号', '密码', '915035')    #用户中心>>软件ID 生成一个替换 96001# 2.准备验证码图片数据im = open('files/code.png', 'rb').read()                                                    #本地图片文件路径 来替换 a.jpg 有时WIN系统须要//# # 3.发送验证码图片给平台# print(chaojiying.post_pic(im, 9101))                                               #1902 验证码类型  官方网站>>价格体系 3.4+版 print 后要加()chaojiying.report_error('1137615106023600021')# {'err_no': 0, 'err_str': 'OK', 'pic_id': '1137611336023600007', 'pic_str': '289,504|363,378', 'md5': '578486d0431710fbc8b8d4f3f544d9bb'}

4.10验证码(抠图)和超级鹰的使用相关推荐

  1. python—简单数据抓取四(利用超级鹰的ocr识别图片验证码模拟登录超级鹰网站、利用百度云的ocr识别自如租房网价格图片获取到自如网的价格)

    学习目标: python学习二十四 -简单数据抓取四 学习内容: 1.利用超级鹰的ocr识别图片验证码模拟登录超级鹰网站 2.利用百度云的ocr识别自如租房网的价格图片,获取到自如网的价格数据 1.利 ...

  2. 爬虫进阶之路---处理点触验证码(使用超级鹰API接口处理;以解决12306的图片验证码为例;)

    三大图形验证码之点触验证码 打码平台 超级鹰的使用 12306自动登录 整体代码文件 12306_selenium.py 12306_selenium.py文件代码: chaojiying.py文件代 ...

  3. 针对“天眼查”选字验证调用超级鹰平台解决方案

    from selenium.webdriver import ActionChains # 动作链 from hashlib import md5 ### md5加密保护密码 import time ...

  4. python爬虫——利用超级鹰识别验证码并进行古诗网进行模拟登录

    目录 前言 一.超级鹰的注册 二.利用xpath解析登录页面的验证码图片 三.利用超级鹰识别获取验证码 四.模拟浏览器发送请求进行模拟登录 五.验证是否模拟登录成功 前言 本文章是利用python爬虫 ...

  5. Python使用网络抓包的方式,利用超级鹰平台识别验证码登录爬取古诗文网、上篇--识别验证码

    Python使用网络抓包的方式,利用超级鹰平台识别验证码登录,<爬取古诗文网>. 上篇–识别验证码 序言: 哈喽,各位小可爱们,我又来了,这次我新学习到的内容是python爬虫识别验证码. ...

  6. selenium 超级鹰 通过携程滑块和汉字验证码

    大概流程 1.进入页面点击同意按钮. 2.得到滑块和滑块区域的xpath 3.定位滑块,设置按住事件,进行拖动 4.xpath定位汉字图片,获取屏幕截图,保存本地 5.超级鹰识别图片返回汉字对应的坐标 ...

  7. 爬虫学习笔记(十八)—— 点触验证码:超级鹰、12306自动登录

    一.打码平台 点触验证码是一种常见的反爬手段. 解决方案有两种:一种是直接解决,这需要深度学习机器学习等图像处理技术,以大量的数据训练识别模型,最终达到模型足矣识别图片中的文字提示和应该点击的区域之间 ...

  8. python反爬虫应对之借助平台超级鹰突破网页验证码识别

    在爬虫过程中,有些网页需要登录才能获取里面的数据,在大部分的登录过程中,都会需要一个叫验证码识别,目前的网页有各种各样的验证码,有数字加字母的组合,有物品识别等等 在代码进行网页爬取过程中,如果由人为 ...

  9. 2020-08-27 RPA uipath入门demo,超级鹰实现验证码自动登录,自动搜索和拉取数据到excel,robot和Orchestrator共同实现定时安排机器人执行任务。

    资源地址:https://download.csdn.net/download/u012742970/12773335 本文主要讲解uipath studio,uirobot,Orchestrator ...

  10. 『python爬虫』26. selenium与超级鹰处理复杂验证码的处理(保姆级图文)

    目录 1. 图片选择类验证码 2. 滑块验证码 3. 滑块出错,不加载 总结 欢迎关注 『python爬虫』 专栏,持续更新中 欢迎关注 『python爬虫』 专栏,持续更新中 1. 图片选择类验证码 ...

最新文章

  1. React总结篇之十_动画
  2. python—类和对象之浅拷贝和深拷贝详细讲解
  3. 4028: [HEOI2015]公约数数列
  4. linux怎么使多条命令同时执行
  5. ASV2011新功能逐个数
  6. [CF438D]The Child and Sequence
  7. 合肥工业大学机器人足球仿真robcup作业一(python实现)附代码有注释
  8. netbeans卸载
  9. 上海交大团队制备全球最大规模的光量子计算芯片
  10. freeMarker导出word带图片
  11. moviepy音视频剪辑:视频半自动追踪人脸打马赛克
  12. 详细说明register关键字
  13. css显示苹方字体,苹方字体合集
  14. hibernate查找数据库中所有内容cannot be cast to com.shzy.model.Materia
  15. 华为云·云享专家李万龙: IoT 梦想,从0到1的实现
  16. linux文件取交集、差集、并集
  17. xpose和sxpose,谁是卧底?
  18. 机器视觉丨转角同轴光源工作原理及打光案例和产品尺寸图
  19. 利用XSS进行网页钓鱼
  20. 施耐德M580系列CPU下装注意事项

热门文章

  1. Java类加载机制--类加载过程(解析)
  2. 春节假期,把“电影院”搬回家,泰捷WEBOX T1S 投影仪全面评测
  3. Java 生成 验证码图片
  4. a与a的共轭转置相乘_线性代数A矩阵乘以A的转置的含义或者几何意义
  5. 手风琴几排簧好_四排簧手风琴适合初学者么
  6. PX4从放弃到精通(十八):参数
  7. 逻辑学是计算机科学的一个重要分支,逻辑学在计算机科学中应用.doc
  8. Day 35 年会抽奖 + 抄送列表
  9. java新手代码翻译成中文_急!老师让我把以下代码翻译成中文的
  10. 8086 CPU的寄存器结构