利用Pytersseract辨識高鐵的驗證碼?
2020/03/31 01:56 下午
Python網路爬蟲討論版
Martin
觀看數:13
回答數:1
收藏數:0
在高鐵的訂票網站中:https://irs.thsrc.com.tw/IMINT/?locale=tw
會需要輸入辨識碼,
但是利用Pytesseract辨識時,似乎無法辨識,
print(code)的時候,沒有輸出
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
}
response = requests.get('https://irs.thsrc.com.tw/IMINT/captImg/McVxSVuDFh.jpg',headers=headers)
img = Image.open(BytesIO(response.content))
code = pytesseract.image_to_string(img)
print(code)