网站使用了Kaptcha来生成验证码,如何即时识别呢?下载验证码进行识别时总是找不到正确的url
如题,我用用以下代码测试后报错,主要是找不到验证码的url。import requests
from bs4 import BeautifulSoup
from PIL import Image
import ddddocr
url = "http://58.49.47.121:81/n_score/index.jsp"
response = requests.get(url)
soup = BeautifulSoup(response.content, 'lxml')
captcha_img_tag=soup.find(id="img_randCode")
captcha_img_url=captcha_img_tag["src"]
#下载验证码图片
r = requests.get(captcha_img_url)
with open("yzm.png",'rb') as f:
f.write(r.content)
#识别验证码上文字
ocr=ddddocr.DdddOcr()
with open("yzm.png",'rb') as f:
image=f.read()
res=ocr.classification(image)
print(res)
虽然这个验证码的url是http://58.49.47.121:81/n_score/Kaptcha.do,但是如果直接从这个网站上下载进行识别,能否匹配http://58.49.47.121:81/n_score/index.jsp网站上的信息呢?