lexiforest / curl_cffi

Python binding for curl-impersonate fork via cffi. A http client that can impersonate browser tls/ja3/http2 fingerprints.
https://curl-cffi.readthedocs.io/
MIT License
2.49k stars 265 forks source link

OCR 錯誤在 0.7.3版本 #432

Closed l7123222l7 closed 2 days ago

l7123222l7 commented 1 week ago

0.7.1版本 OCR使用正常 可以識別 但在0.7.3版本中 出現了 這該如何解決 OCR Error: cannot identify image file <_io.BytesIO object at 0x7f91e2057ec0> OCR Error: cannot identify image file <_io.BytesIO object at 0x7f91e1dc8040> OCR Error: cannot identify image file <_io.BytesIO object at 0x7f91e1eb9a30>

` async def captcha_challenge(self, response_text, origin, s, impersonate_option, headers, proxies, url): soup = BeautifulSoup(response_text, 'html.parser') captcha_id = soup.find('input', {'name': 'WAF_CAPTCHA_ID'}).get('value') captcha_image_url = soup.find('img', {'id': 'ui-captcha-image'}).get('src')

    if captcha_id and captcha_image_url:
        captcha_image_url = urllib.parse.urljoin(origin, captcha_image_url)
        captcha_response = await s.get(captcha_image_url, **impersonate_option, headers=headers, proxies=proxies, verify=False, timeout=15, allow_redirects=True)

        if captcha_response.status_code == 200:
            try:
                # 轉換處理
                from io import BytesIO
                buffer = BytesIO(captcha_response.content)
                content = buffer.getvalue()

                captcha_code = self.ocr.classification(content)
                print(captcha_code)

            except Exception as e:
                print(f"OCR Error: {str(e)}")
    return None`
lexiforest commented 2 days ago

It's not part of this project's scope. You need to reach out to your vendor or find the root cause.