support indievox/tixcraft captcha.

master
Max 2023-01-14 17:53:32 +08:00
parent 42fffdd3af
commit 493da61771
1 changed files with 6 additions and 3 deletions

View File

@ -5,10 +5,9 @@ from PIL import Image
from io import BytesIO from io import BytesIO
class NonBrowser(): class NonBrowser():
def __init__(self) -> None: def __init__(self, domain_name = "tixcraft.com") -> None:
self.Session = requests.session() self.Session = requests.session()
self.url = "https://tixcraft.com/ticket/captcha" self.Set_Domain(domain_name)
self.refresh_url = "https://tixcraft.com/ticket/captcha?refresh=1"
def Set_cookies(self,cookies:dict): def Set_cookies(self,cookies:dict):
for cookie in cookies: for cookie in cookies:
@ -18,6 +17,10 @@ class NonBrowser():
def set_headers(self,header:str): def set_headers(self,header:str):
self.Session.headers = header self.Session.headers = header
def Set_Domain(self, domain_name, captcha_url="ticket/captcha", refresh_url="ticket/captcha?refresh=1"):
self.url = "https://%s/%s" % (domain_name, captcha_url)
self.refresh_url = "https://%s/%s" % (domain_name, refresh_url)
def Request_Captcha(self): def Request_Captcha(self):
img = Image.open(BytesIO(self.Session.get(self.url, stream = True).content)) img = Image.open(BytesIO(self.Session.get(self.url, stream = True).content))
output_buffer = BytesIO() output_buffer = BytesIO()