请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

登陆识别验证码

代码没有报错 却识别不了验证码

from selenium import webdriver
from PIL import Image
from ShowapiRequest import ShowapiRequest
import time

driver = webdriver.Chrome()
driver.get(“https://zwdtuser.sh.gov.cn/uc/login/login.jsp”)
time.sleep(5)

def get_code_image(file_name):
driver.save_screenshot(file_name)
code_element = driver.find_element_by_id(“img”)
print(code_element.location)#坐标定位验证码位置(“x”:123,“y”:345)
left = code_element.location[‘x’]
top = code_element.location[‘y’]
right = code_element.size[‘width’]+left
height = code_element.size[‘height’]+top
im = Image.open(file_name)
img = im.crop((left,top,right,height))
img.save(file_name)

def code_online(file_name):
r = ShowapiRequest(“http://route.shouapi.com/184-5”, “id”, “ccad”)#账个人户和密码隐藏
r.addBodyPara(“img_base64”, “”)
r.addBodyPara(“typeId”,“35”)
r.addBodyPara(“convert_to_jpg”,“0”)
r.addBodyPara(“image”,file_name)
res = r.post()
text = res.json()[‘showapi_res_body’][‘Result’]
print(res.text)
return text
driver.close()

正在回答 回答被采纳积分+3

插入代码

1回答

威哥V5 2019-03-01 17:56:00

已解决。

//img1.sycdn.imooc.com//szimg/5c79071c0001bf0a10060882.jpg

low 代码 没问题了

0 回复 有任何疑惑可以回复我~
  • 之前没看到,在学习。验证码确实识别不了,你那验证码用第3方不好识别
    回复 有任何疑惑可以回复我~ 2019-03-01 18:24:26
  • Mushishi 回复 威哥V5 #2
    哈哈,这个只是一种解决方案。叫你们如何解决遇见类似问题怎么解决。
    回复 有任何疑惑可以回复我~ 2019-03-01 19:19:45
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号