准备目标网站 :https://kyfw.12306.cn/otn/login/init安装PIL模块: pip3 install pillow 或 pip3 --default-timeout=100 install -U pillow 第三方图像处理库(图片定位裁剪)准备一个浏览器驱动(版本不要差太多) chromedriver.exe 下载:https://npm.taobao.org/mirrors/chromedriver/验证码识别网站(超级鹰):http://www.chaojiying.com/ 需要注册,使用方法 参考#页面中验证码识别;https://www.cnblogs.com/guokaifeng/p/11536706.html需求分析通过selenium模块来实现模拟登录- 难点:对验证码的自动识别(验证码要一次获取,刷新的话会更改验证码)- 解决方案:对验证码区域进行截取(使用PIL模块的Image),用超级鹰来获取正确验证码的坐标,然后由selenium实现登录 实现代码from PIL import Image #导入Image截图from time import sleep from selenium importwebdriverfrom Cjy import Chaojiying_Client # 导入超级鹰验证码识别from selenium.webdriver importActionChains # 导