update for kham.

master
Max 2023-11-02 14:09:42 +08:00 committed by GitHub
parent 852c505f93
commit 0e58b9b7ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 25 deletions

View File

@ -119,6 +119,7 @@ def remove_html_tags(text):
if not text is None: if not text is None:
clean = re.compile('<.*?>') clean = re.compile('<.*?>')
ret = re.sub(clean, '', text) ret = re.sub(clean, '', text)
ret = ret.strip()
return ret return ret
def sx(s1): def sx(s1):
@ -9861,21 +9862,8 @@ def hkam_date_auto_select(driver, domain_name, config_dict):
row_text = "" row_text = ""
if '立即訂購' in row_text or '點此購票' in row_text: if '立即訂購' in row_text or '點此購票' in row_text:
try: if "<button" in row_html:
# for kham.com
my_css_selector = "a > button"
if 'ticket.com' in domain_name:
my_css_selector = "td > button.btn"
el_btn = row.find_element(By.CSS_SELECTOR, my_css_selector)
if not el_btn is None:
if el_btn.is_enabled():
#print("row's button enabled.")
row_is_enabled=True row_is_enabled=True
except Exception as exc:
if show_debug_message:
print(exc)
pass
if row_is_enabled: if row_is_enabled:
formated_area_list.append(row) formated_area_list.append(row)
@ -10064,6 +10052,10 @@ def kham_area_auto_select(driver, domain_name, config_dict, area_keyword_item):
if '售完' in row_text: if '售完' in row_text:
row_text = "" row_text = ""
if len(row_text) > 0:
if ' Soldout' in row_html:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -10073,22 +10065,18 @@ def kham_area_auto_select(driver, domain_name, config_dict, area_keyword_item):
if config_dict["ticket_number"] > 1: if config_dict["ticket_number"] > 1:
maybe_ticket_count = row_text[-1:] maybe_ticket_count = row_text[-1:]
if maybe_ticket_count.isdigit(): if maybe_ticket_count.isdigit():
ticket_count_element = None if "<td" in row_html:
try: td_array = row_html.split("<td")
my_css_selector = "td:nth-child(4)" if len(td_array) > 0:
ticket_count_element = row.find_element(By.CSS_SELECTOR, my_css_selector) td_target = "<td" + td_array[len(td_array)-1]
if not ticket_count_element is None: ticket_count_text = remove_html_tags(td_target)
ticket_count_text = ticket_count_element.text print("ticket_count_text:", ticket_count_text)
if ticket_count_text.isdigit(): if ticket_count_text.isdigit():
if int(ticket_count_text) < config_dict["ticket_number"]: if int(ticket_count_text) < config_dict["ticket_number"]:
if show_debug_message: if show_debug_message:
print("skip this row, because ticket_count available only:", ticket_count_text) print("skip this row, because ticket_count available only:", ticket_count_text)
# skip this row. # skip this row.
row_text = "" row_text = ""
except Exception as exc:
if show_debug_message:
print(exc)
if len(row_text) > 0: if len(row_text) > 0:
row_text = format_keyword_string(row_text) row_text = format_keyword_string(row_text)