From 2b53e1895710bdef7a16ad98877e47314c496e2e Mon Sep 17 00:00:00 2001 From: Anyexyz Date: Thu, 21 Dec 2023 14:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E4=BA=86utility=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utility.py | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/utility.py b/utility.py index 627f5e0..96456d4 100644 --- a/utility.py +++ b/utility.py @@ -15,18 +15,9 @@ def encrypt(t): cipher_text = b64encode(cipher.encrypt(t.encode())) return cipher_text.decode() - -def md5(s): - import hashlib - m = hashlib.md5() - m.update(s.encode()) - return m.hexdigest() - - def cap_recognize(cap): return DdddOcr().classification(denoise(cap)) - def denoise(cap): img = Image.open(BytesIO(cap)) steps = ((1, 1), (1, 0), (1, -1), (0, 1), (0, -1), (-1, 1), (-1, 0), (-1, -1)) @@ -54,23 +45,4 @@ def denoise(cap): buf = BytesIO() img.save(buf, format='PNG') - return buf.getvalue() - - -if __name__ == '__main__': - import requests - import re - - bjySession = requests.session() - bjySession.timeout = 5 # set session timeout - touch = bjySession.get(url="https://m.bjyouth.net/site/login") - capUrl = "https://m.bjyouth.net" + re.findall( - r'src="(/site/captcha.+)" alt=', touch.text)[0] - cap1 = bjySession.get(url=capUrl).content - cap2 = denoise(cap1) - - img = Image.open(BytesIO(cap1)) - img.show() - - img = Image.open(BytesIO(cap2)) - img.show() + return buf.getvalue() \ No newline at end of file