一、识别验证码的操作
第三方自动识别
1.超级鹰
- 注册
- 登录
- 题分
- 创建软件(ID)
- 下载示例代码
二、识别验证码的编码流程
1.下载验证码图片到本地
import requests, os
from lxml import etree
from chaojiying_Python import chaojiying
from chaojiying_Python.chaojiying import Chaojiying_Client
if __name__ == '__main__':
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36',
}
url = 'https://so.gushiwen.cn/user/login.aspx'
page_text = requests.get(url=url, headers=headers).text
page_html = etree.HTML(page_text)
img_url = 'https://so.gushiwen.cn' + page_html.xpath("//div[@class='mainreg2']/div[4]/img/@src")[0]
img_data = requests.get(url=img_url, headers=headers).content
with open('./code.jpg', 'wb') as f:
f.write(img_data)
2. 调用超级鹰的示例程序进行验证码的识别
chaojiying = Chaojiying_Client('fei19961028', 'zhrmghgwswswws', '915658') # 用户中心>>软件ID 生成一个替换 96001
im = open('code.jpg', 'rb').read() # 本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
print(chaojiying.PostPic(im, 1902)) # 1902 验证码类型 官方网站>>价格体系