2024-01-12, restart browser with interval.
parent
49ce76808d
commit
c0acf7fd89
|
@ -19,6 +19,9 @@ class NonBrowser():
|
||||||
ret = True
|
ret = True
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def Get_cookies(self):
|
||||||
|
return self.Session.cookies.get_dict()
|
||||||
|
|
||||||
def set_headers(self, header:str):
|
def set_headers(self, header:str):
|
||||||
self.Session.headers = header
|
self.Session.headers = header
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ try:
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
CONST_APP_VERSION = "MaxBot (2024.01.11)"
|
CONST_APP_VERSION = "MaxBot (2024.01.12)"
|
||||||
|
|
||||||
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
|
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
|
||||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||||
|
@ -807,7 +807,7 @@ def close_browser_tabs(driver):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_driver_by_config(config_dict):
|
def get_driver_by_config(config_dict):
|
||||||
global driver
|
driver = None
|
||||||
|
|
||||||
# read config.
|
# read config.
|
||||||
homepage = config_dict["homepage"]
|
homepage = config_dict["homepage"]
|
||||||
|
@ -7432,7 +7432,10 @@ def set_non_browser_cookies(driver, url, Captcha_Browser):
|
||||||
domain_name = url.split('/')[2]
|
domain_name = url.split('/')[2]
|
||||||
#PS: need set cookies once, if user change domain.
|
#PS: need set cookies once, if user change domain.
|
||||||
if not Captcha_Browser is None:
|
if not Captcha_Browser is None:
|
||||||
|
try:
|
||||||
Captcha_Browser.Set_cookies(driver.get_cookies())
|
Captcha_Browser.Set_cookies(driver.get_cookies())
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
Captcha_Browser.Set_Domain(domain_name)
|
Captcha_Browser.Set_Domain(domain_name)
|
||||||
|
|
||||||
def ticketmaster_parse_zone_info(driver, config_dict):
|
def ticketmaster_parse_zone_info(driver, config_dict):
|
||||||
|
@ -12309,7 +12312,7 @@ def get_current_url(driver):
|
||||||
for each_error_string in exit_bot_error_strings:
|
for each_error_string in exit_bot_error_strings:
|
||||||
if isinstance(str_exc, str):
|
if isinstance(str_exc, str):
|
||||||
if each_error_string in str_exc:
|
if each_error_string in str_exc:
|
||||||
print('quit bot by error:', each_error_string)
|
print('quit bot by error:', each_error_string, driver)
|
||||||
is_quit_bot = True
|
is_quit_bot = True
|
||||||
driver.quit()
|
driver.quit()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
@ -12320,6 +12323,21 @@ def get_current_url(driver):
|
||||||
|
|
||||||
return url, is_quit_bot
|
return url, is_quit_bot
|
||||||
|
|
||||||
|
def reset_webdriver(driver, config_dict, url):
|
||||||
|
new_driver = None
|
||||||
|
try:
|
||||||
|
cookies = driver.get_cookies()
|
||||||
|
driver.close()
|
||||||
|
config_dict["homepage"]=url
|
||||||
|
new_driver = get_driver_by_config(config_dict)
|
||||||
|
for cookie in cookies:
|
||||||
|
new_driver.add_cookie(cookie);
|
||||||
|
new_driver.get(url)
|
||||||
|
driver = new_driver
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
return new_driver
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
config_dict = get_config_dict(args)
|
config_dict = get_config_dict(args)
|
||||||
|
|
||||||
|
@ -12377,13 +12395,13 @@ def main(args):
|
||||||
if config_dict["ocr_captcha"]["enable"]:
|
if config_dict["ocr_captcha"]["enable"]:
|
||||||
ocr = ddddocr.DdddOcr(show_ad=False, beta=config_dict["ocr_captcha"]["beta"])
|
ocr = ddddocr.DdddOcr(show_ad=False, beta=config_dict["ocr_captcha"]["beta"])
|
||||||
Captcha_Browser = NonBrowser()
|
Captcha_Browser = NonBrowser()
|
||||||
|
|
||||||
if len(config_dict["advanced"]["tixcraft_sid"]) > 1:
|
if len(config_dict["advanced"]["tixcraft_sid"]) > 1:
|
||||||
set_non_browser_cookies(driver, config_dict["homepage"], Captcha_Browser)
|
set_non_browser_cookies(driver, config_dict["homepage"], Captcha_Browser)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(exc)
|
print(exc)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
maxbot_last_reset_time = time.time()
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
|
@ -12417,10 +12435,16 @@ def main(args):
|
||||||
if is_maxbot_paused:
|
if is_maxbot_paused:
|
||||||
if 'kktix.c' in url:
|
if 'kktix.c' in url:
|
||||||
kktix_dict = kktix_paused_main(driver, url, config_dict, kktix_dict)
|
kktix_dict = kktix_paused_main(driver, url, config_dict, kktix_dict)
|
||||||
|
# sleep more when paused.
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if config_dict["advanced"]["reset_browser_interval"] > 0:
|
||||||
|
maxbot_running_time = time.time() - maxbot_last_reset_time
|
||||||
|
if maxbot_running_time > config_dict["advanced"]["reset_browser_interval"]:
|
||||||
|
driver = reset_webdriver(driver, config_dict, url)
|
||||||
|
maxbot_last_reset_time = time.time()
|
||||||
|
|
||||||
tixcraft_family = False
|
tixcraft_family = False
|
||||||
if 'tixcraft.com' in url:
|
if 'tixcraft.com' in url:
|
||||||
tixcraft_family = True
|
tixcraft_family = True
|
||||||
|
|
|
@ -22,7 +22,7 @@ import sys
|
||||||
import threading
|
import threading
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
CONST_APP_VERSION = "MaxBot (2024.01.11)"
|
CONST_APP_VERSION = "MaxBot (2024.01.12)"
|
||||||
|
|
||||||
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"
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
"user_guess_string": "",
|
"user_guess_string": "",
|
||||||
"remote_url": "\"http://127.0.0.1:16888/\"",
|
"remote_url": "\"http://127.0.0.1:16888/\"",
|
||||||
"auto_reload_page_interval": 0.1,
|
"auto_reload_page_interval": 0.1,
|
||||||
|
"reset_browser_interval": 0.0,
|
||||||
"proxy_server_port": ""
|
"proxy_server_port": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
27
settings.py
27
settings.py
|
@ -39,7 +39,7 @@ try:
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
CONST_APP_VERSION = "MaxBot (2024.01.11)"
|
CONST_APP_VERSION = "MaxBot (2024.01.12)"
|
||||||
|
|
||||||
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
|
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
|
||||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||||
|
@ -133,6 +133,7 @@ def load_translate():
|
||||||
en_us["pass_date_is_sold_out"] = 'Pass date is sold out'
|
en_us["pass_date_is_sold_out"] = 'Pass date is sold out'
|
||||||
en_us["auto_reload_coming_soon_page"] = 'Reload coming soon page'
|
en_us["auto_reload_coming_soon_page"] = 'Reload coming soon page'
|
||||||
en_us["auto_reload_page_interval"] = 'Reload page interval(sec.)'
|
en_us["auto_reload_page_interval"] = 'Reload page interval(sec.)'
|
||||||
|
en_us["reset_browser_interval"] = 'Reset browser interval(sec.)'
|
||||||
en_us["proxy_server_port"] = 'Proxy IP:PORT'
|
en_us["proxy_server_port"] = 'Proxy IP:PORT'
|
||||||
|
|
||||||
en_us["area_select_order"] = 'Area select order'
|
en_us["area_select_order"] = 'Area select order'
|
||||||
|
@ -240,6 +241,7 @@ def load_translate():
|
||||||
zh_tw["pass_date_is_sold_out"] = '避開「搶購一空」的日期'
|
zh_tw["pass_date_is_sold_out"] = '避開「搶購一空」的日期'
|
||||||
zh_tw["auto_reload_coming_soon_page"] = '自動刷新倒數中的日期頁面'
|
zh_tw["auto_reload_coming_soon_page"] = '自動刷新倒數中的日期頁面'
|
||||||
zh_tw["auto_reload_page_interval"] = '自動刷新頁面間隔(秒)'
|
zh_tw["auto_reload_page_interval"] = '自動刷新頁面間隔(秒)'
|
||||||
|
zh_tw["reset_browser_interval"] = '重新啟動瀏覽器間隔(秒)'
|
||||||
zh_tw["proxy_server_port"] = 'Proxy IP:PORT'
|
zh_tw["proxy_server_port"] = 'Proxy IP:PORT'
|
||||||
|
|
||||||
zh_tw["area_select_order"] = '區域排序方式'
|
zh_tw["area_select_order"] = '區域排序方式'
|
||||||
|
@ -347,6 +349,7 @@ def load_translate():
|
||||||
zh_cn["pass_date_is_sold_out"] = '避开“抢购一空”的日期'
|
zh_cn["pass_date_is_sold_out"] = '避开“抢购一空”的日期'
|
||||||
zh_cn["auto_reload_coming_soon_page"] = '自动刷新倒数中的日期页面'
|
zh_cn["auto_reload_coming_soon_page"] = '自动刷新倒数中的日期页面'
|
||||||
zh_cn["auto_reload_page_interval"] = '重新加载间隔(秒)'
|
zh_cn["auto_reload_page_interval"] = '重新加载间隔(秒)'
|
||||||
|
zh_cn["reset_browser_interval"] = '重新启动浏览器间隔(秒)'
|
||||||
zh_cn["proxy_server_port"] = 'Proxy IP:PORT'
|
zh_cn["proxy_server_port"] = 'Proxy IP:PORT'
|
||||||
|
|
||||||
zh_cn["area_select_order"] = '区域排序方式'
|
zh_cn["area_select_order"] = '区域排序方式'
|
||||||
|
@ -455,6 +458,7 @@ def load_translate():
|
||||||
ja_jp["pass_date_is_sold_out"] = '「売り切れ」公演を避ける'
|
ja_jp["pass_date_is_sold_out"] = '「売り切れ」公演を避ける'
|
||||||
ja_jp["auto_reload_coming_soon_page"] = '公開予定のページをリロード'
|
ja_jp["auto_reload_coming_soon_page"] = '公開予定のページをリロード'
|
||||||
ja_jp["auto_reload_page_interval"] = 'リロード間隔(秒)'
|
ja_jp["auto_reload_page_interval"] = 'リロード間隔(秒)'
|
||||||
|
ja_jp["reset_browser_interval"] = 'ブラウザの再起動間隔(秒)'
|
||||||
ja_jp["proxy_server_port"] = 'Proxy IP:PORT'
|
ja_jp["proxy_server_port"] = 'Proxy IP:PORT'
|
||||||
|
|
||||||
ja_jp["area_select_order"] = 'エリアソート方法'
|
ja_jp["area_select_order"] = 'エリアソート方法'
|
||||||
|
@ -687,6 +691,7 @@ def get_default_config():
|
||||||
config_dict["advanced"]["remote_url"] = "http://127.0.0.1:%d/" % (CONST_SERVER_PORT)
|
config_dict["advanced"]["remote_url"] = "http://127.0.0.1:%d/" % (CONST_SERVER_PORT)
|
||||||
|
|
||||||
config_dict["advanced"]["auto_reload_page_interval"] = 0.1
|
config_dict["advanced"]["auto_reload_page_interval"] = 0.1
|
||||||
|
config_dict["advanced"]["reset_browser_interval"] = 0
|
||||||
config_dict["advanced"]["proxy_server_port"] = ""
|
config_dict["advanced"]["proxy_server_port"] = ""
|
||||||
|
|
||||||
return config_dict
|
return config_dict
|
||||||
|
@ -776,6 +781,7 @@ def btn_save_act(language_code, slience_mode=False):
|
||||||
global chk_state_pass_date_is_sold_out
|
global chk_state_pass_date_is_sold_out
|
||||||
global chk_state_auto_reload_coming_soon_page
|
global chk_state_auto_reload_coming_soon_page
|
||||||
global txt_auto_reload_page_interval
|
global txt_auto_reload_page_interval
|
||||||
|
global txt_reset_browser_intervalv
|
||||||
global txt_proxy_server_port
|
global txt_proxy_server_port
|
||||||
|
|
||||||
global txt_tixcraft_sid
|
global txt_tixcraft_sid
|
||||||
|
@ -986,8 +992,14 @@ def btn_save_act(language_code, slience_mode=False):
|
||||||
config_dict["advanced"]["auto_guess_options"] = bool(chk_state_auto_guess_options.get())
|
config_dict["advanced"]["auto_guess_options"] = bool(chk_state_auto_guess_options.get())
|
||||||
|
|
||||||
config_dict["advanced"]["auto_reload_page_interval"] = float(txt_auto_reload_page_interval.get().strip())
|
config_dict["advanced"]["auto_reload_page_interval"] = float(txt_auto_reload_page_interval.get().strip())
|
||||||
|
config_dict["advanced"]["reset_browser_interval"] = float(txt_reset_browser_interval.get().strip())
|
||||||
config_dict["advanced"]["proxy_server_port"] = txt_proxy_server_port.get().strip()
|
config_dict["advanced"]["proxy_server_port"] = txt_proxy_server_port.get().strip()
|
||||||
|
|
||||||
|
if config_dict["advanced"]["reset_browser_interval"] > 0:
|
||||||
|
if config_dict["advanced"]["reset_browser_interval"] < 20:
|
||||||
|
# min value is 20 seconds.
|
||||||
|
config_dict["advanced"]["reset_browser_interval"] = 20
|
||||||
|
|
||||||
|
|
||||||
# save config.
|
# save config.
|
||||||
if is_all_data_correct:
|
if is_all_data_correct:
|
||||||
|
@ -1286,6 +1298,7 @@ def applyNewLanguage():
|
||||||
global lbl_block_facebook_network_recommand
|
global lbl_block_facebook_network_recommand
|
||||||
|
|
||||||
global lbl_auto_reload_page_interval
|
global lbl_auto_reload_page_interval
|
||||||
|
global lbl_reset_browser_interval
|
||||||
global lbl_proxy_server_port
|
global lbl_proxy_server_port
|
||||||
|
|
||||||
lbl_homepage.config(text=translate[language_code]["homepage"])
|
lbl_homepage.config(text=translate[language_code]["homepage"])
|
||||||
|
@ -1322,6 +1335,7 @@ def applyNewLanguage():
|
||||||
lbl_block_facebook_network_recommand.config(text=translate[language_code]["recommand_enable"])
|
lbl_block_facebook_network_recommand.config(text=translate[language_code]["recommand_enable"])
|
||||||
|
|
||||||
lbl_auto_reload_page_interval.config(text=translate[language_code]["auto_reload_page_interval"])
|
lbl_auto_reload_page_interval.config(text=translate[language_code]["auto_reload_page_interval"])
|
||||||
|
lbl_reset_browser_interval.config(text=translate[language_code]["reset_browser_interval"])
|
||||||
lbl_proxy_server_port.config(text=translate[language_code]["proxy_server_port"])
|
lbl_proxy_server_port.config(text=translate[language_code]["proxy_server_port"])
|
||||||
|
|
||||||
lbl_headless.config(text=translate[language_code]["headless"])
|
lbl_headless.config(text=translate[language_code]["headless"])
|
||||||
|
@ -1944,6 +1958,17 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X):
|
||||||
|
|
||||||
group_row_count +=1
|
group_row_count +=1
|
||||||
|
|
||||||
|
global lbl_reset_browser_interval
|
||||||
|
lbl_reset_browser_interval = Label(frame_group_header, text=translate[language_code]['reset_browser_interval'])
|
||||||
|
lbl_reset_browser_interval.grid(column=0, row=group_row_count, sticky = E)
|
||||||
|
|
||||||
|
global txt_reset_browser_interval
|
||||||
|
txt_reset_browser_interval_value = StringVar(frame_group_header, value=config_dict["advanced"]["reset_browser_interval"])
|
||||||
|
txt_reset_browser_interval = Entry(frame_group_header, width=30, textvariable = txt_reset_browser_interval_value)
|
||||||
|
txt_reset_browser_interval.grid(column=1, row=group_row_count, sticky = W)
|
||||||
|
|
||||||
|
group_row_count +=1
|
||||||
|
|
||||||
global lbl_proxy_server_port
|
global lbl_proxy_server_port
|
||||||
lbl_proxy_server_port = Label(frame_group_header, text=translate[language_code]['proxy_server_port'])
|
lbl_proxy_server_port = Label(frame_group_header, text=translate[language_code]['proxy_server_port'])
|
||||||
lbl_proxy_server_port.grid(column=0, row=group_row_count, sticky = E)
|
lbl_proxy_server_port.grid(column=0, row=group_row_count, sticky = E)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "proxy_server_port": ""}}
|
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "reset_browser_interval": 0.0, "proxy_server_port": ""}}
|
Loading…
Reference in New Issue