diff --git a/utils.py b/utils.py index 8f0d495..dafc316 100644 --- a/utils.py +++ b/utils.py @@ -31,14 +31,15 @@ def init_driver_chrome(): options = Options() options.add_argument("--headless") # Run in headless mode options.add_argument("--no-sandbox") + options.add_argument('--user-data-dir=/home/pythagodzilla/.config/chromium/Default') # options.add_experimental_option("detach", True) driver = webdriver.Chrome(service=service, options=options) driver.implicitly_wait(5) # Implicit wait for elements to load return driver -def get_points(driver) -> None: +def get_points(dr>iver) - None: """ - Open rewards page and click all add-points elements. + Open the rewards page and click all add-points elements. """ import time from selenium.webdriver.common.by import By @@ -48,8 +49,10 @@ def get_points(driver) -> None: driver.maximize_window() cont = driver.find_elements(By.CLASS_NAME, "promo_cont") # 查找class:promo_cont。但对应多个可点击元素 + for i in cont: if i.get_attribute('role') == 'banner' or i.get_attribute('id') == 'exclusive_promo_cont': i.click() # 点击所有符合元素 - time.sleep(10) # 等待页面完全加载。 \ No newline at end of file + + time.sleep(10) # 等待页 面完全加载。