2023-06-30, change version code

master
CHUN YU YAO 2023-07-06 23:29:58 +08:00
parent 94f937c000
commit 92af079920
4 changed files with 119 additions and 87 deletions

View File

@ -53,7 +53,7 @@ import webbrowser
import argparse import argparse
import itertools import itertools
CONST_APP_VERSION = "MaxBot (2023.6.29) ver3" CONST_APP_VERSION = "MaxBot (2023.6.30)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -2748,32 +2748,40 @@ def tixcraft_get_ocr_answer(driver, ocr, ocr_captcha_image_source, Captcha_Brows
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
image_id = 'TicketForm_verifyCode-image' image_id = 'TicketForm_verifyCode-image'
if 'indievox.com' in domain_name: image_element = None
#image_id = 'TicketForm_verifyCode-image'
pass
try: try:
form_verifyCode_base64 = driver.execute_async_script(""" my_css_selector = "#" + image_id
var canvas = document.createElement('canvas'); image_element = driver.find_elements(By.CSS_SELECTOR, my_css_selector)
var context = canvas.getContext('2d');
var img = document.getElementById('%s');
if(img!=null) {
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0);
callback = arguments[arguments.length - 1];
callback(canvas.toDataURL()); }
""" % (image_id))
if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
if img_base64 is None:
if not Captcha_Browser is None:
print("canvas get image fail, use plan_b: NonBrowser")
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
except Exception as exc: except Exception as exc:
if show_debug_message:
print("canvas exception:", str(exc))
pass pass
if not image_element is None:
if 'indievox.com' in domain_name:
#image_id = 'TicketForm_verifyCode-image'
pass
try:
form_verifyCode_base64 = driver.execute_async_script("""
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var img = document.getElementById('%s');
if(img!=null) {
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0);
callback = arguments[arguments.length - 1];
callback(canvas.toDataURL()); }
""" % (image_id))
if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
if img_base64 is None:
if not Captcha_Browser is None:
print("canvas get image fail, use plan_b: NonBrowser")
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
except Exception as exc:
if show_debug_message:
print("canvas exception:", str(exc))
pass
if not img_base64 is None: if not img_base64 is None:
try: try:
ocr_answer = ocr.classification(img_base64) ocr_answer = ocr.classification(img_base64)
@ -7756,24 +7764,32 @@ def ibon_auto_ocr(driver, config_dict, ocr, away_from_keyboard_enable, previous_
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha()) img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
image_id = 'chk_pic' image_id = 'chk_pic'
image_element = None
try: try:
form_verifyCode_base64 = driver.execute_async_script(""" my_css_selector = "#" + image_id
var canvas = document.createElement('canvas'); image_element = driver.find_elements(By.CSS_SELECTOR, my_css_selector)
var context = canvas.getContext('2d');
var img = document.getElementById('%s');
if(img!=null) {
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0);
callback = arguments[arguments.length - 1];
callback(canvas.toDataURL()); }
""" % (image_id))
if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
except Exception as exc: except Exception as exc:
if show_debug_message:
print("canvas exception:", str(exc))
pass pass
if not image_element is None:
try:
form_verifyCode_base64 = driver.execute_async_script("""
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var img = document.getElementById('%s');
if(img!=null) {
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0);
callback = arguments[arguments.length - 1];
callback(canvas.toDataURL()); }
""" % (image_id))
if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
except Exception as exc:
if show_debug_message:
print("canvas exception:", str(exc))
pass
if not img_base64 is None: if not img_base64 is None:
try: try:
ocr_answer = ocr.classification(img_base64) ocr_answer = ocr.classification(img_base64)
@ -9748,24 +9764,32 @@ def kham_auto_ocr(driver, config_dict, ocr, away_from_keyboard_enable, previous_
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha()) img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
image_id = 'chk_pic' image_id = 'chk_pic'
image_element = None
try: try:
form_verifyCode_base64 = driver.execute_async_script(""" my_css_selector = "#" + image_id
var canvas = document.createElement('canvas'); image_element = driver.find_elements(By.CSS_SELECTOR, my_css_selector)
var context = canvas.getContext('2d');
var img = document.getElementById('%s');
if(img!=null) {
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0);
callback = arguments[arguments.length - 1];
callback(canvas.toDataURL()); }
""" % (image_id))
if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
except Exception as exc: except Exception as exc:
if show_debug_message:
print("canvas exception:", str(exc))
pass pass
if not image_element is None:
try:
form_verifyCode_base64 = driver.execute_async_script("""
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var img = document.getElementById('%s');
if(img!=null) {
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0);
callback = arguments[arguments.length - 1];
callback(canvas.toDataURL()); }
""" % (image_id))
if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
except Exception as exc:
if show_debug_message:
print("canvas exception:", str(exc))
pass
if not img_base64 is None: if not img_base64 is None:
try: try:
ocr_answer = ocr.classification(img_base64) ocr_answer = ocr.classification(img_base64)
@ -10627,8 +10651,16 @@ def ticketplus_auto_ocr(driver, config_dict, ocr, previous_answer, Captcha_Brows
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha()) img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
image_id = 'span.captcha-img' image_id = 'span.captcha-img'
image_element = None
try: try:
form_verifyCode_base64 = driver.execute_async_script(""" my_css_selector = image_id
image_element = driver.find_elements(By.CSS_SELECTOR, my_css_selector)
except Exception as exc:
pass
if not image_element is None:
try:
form_verifyCode_base64 = driver.execute_async_script("""
function svgToPng(svg, callback) { function svgToPng(svg, callback) {
const url = getSvgUrl(svg); const url = getSvgUrl(svg);
svgUrlToPng(url, (imgData) => { svgUrlToPng(url, (imgData) => {
@ -10664,13 +10696,13 @@ svgToPng(svg, (imgData) => {
callback = arguments[arguments.length - 1]; callback = arguments[arguments.length - 1];
callback(imgData); callback(imgData);
}); } }); }
""" % (image_id)) """ % (image_id))
if not form_verifyCode_base64 is None: if not form_verifyCode_base64 is None:
img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1]) img_base64 = base64.b64decode(form_verifyCode_base64.split(',')[1])
except Exception as exc: except Exception as exc:
if show_debug_message: if show_debug_message:
print("canvas exception:", str(exc)) print("canvas exception:", str(exc))
pass pass
if not img_base64 is None: if not img_base64 is None:
try: try:
ocr_answer = ocr.classification(img_base64) ocr_answer = ocr.classification(img_base64)

View File

@ -22,7 +22,7 @@ import base64
import threading import threading
import subprocess import subprocess
CONST_APP_VERSION = "MaxBot (2023.6.29)" CONST_APP_VERSION = "MaxBot (2023.6.30)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -34,7 +34,7 @@ ssl._create_default_https_context = ssl._create_unverified_context
import socket import socket
CONST_APP_VERSION = "MaxBot (2023.6.29) ver3" CONST_APP_VERSION = "MaxBot (2023.6.30)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"

View File

@ -28,7 +28,7 @@ import asyncio
import tornado import tornado
from tornado.web import Application from tornado.web import Application
CONST_APP_VERSION = "MaxBot (2023.6.29)" CONST_APP_VERSION = "MaxBot (2023.6.30)"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"