Modify: auto ocr fix

master
lovefirst02 2023-01-12 23:49:20 +08:00
parent 7f3524170d
commit dd7bae884b
3 changed files with 19 additions and 10 deletions

View File

@ -27,7 +27,12 @@ class NonBrowser():
return base64_data
def Request_Refresh_Captcha(self) -> str:
try:
result = self.Session.get(self.refresh_url, stream = True)
if result.status_code == 200:
json_data = json.loads(result.text)
return json_data.get("url","")
else:
return ""
except Exception as e:
return ""

View File

@ -1676,17 +1676,21 @@ def tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit):
ocr_total_count = 0 #ocr 總次數
orc_answer = None
while True:
ocr_count += 1
ocr_total_count += 1
if ocr_total_count > 6: #如果總次數大於6次, 直接手動輸入
if ocr_total_count >= 6: #如果總次數大於6次, 直接手動介入
orc_answer = None
break
if ocr_count > 3: #如果次數大於3次, 取得新的Captcha
if ocr_count >= 3: #如果次數大於3次, 取得新的Captcha
print("Get New Captcha")
new_captcha_url = Non_Browser.Request_Refresh_Captcha() #取得新的CAPTCHA
if new_captcha_url != "":
if new_captcha_url != "": #如果capthca取得成功繼續OCR, 失敗直接手動介入
ocr_count = 0
tixcraft_change_captcha(driver,new_captcha_url) #更改CAPTCHA圖
continue
else:
orc_answer = None
break
ocr_count += 1
ocr_total_count += 1
img_base64 = base64.b64decode(Non_Browser.Request_Captcha())
if not ocr is None:
try:

View File

@ -1 +1 @@
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "auto_submit": false}, "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "auto_guess_options": false, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "0", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "0", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": false, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "adblock_plus_enable": true}, "debug": false}
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "auto_submit": false}, "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "auto_guess_options": false, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "adblock_plus_enable": true}, "debug": false}