小修小补
This commit is contained in:
parent
b8390a54d5
commit
e6cd86f70b
9
utils.py
9
utils.py
@ -31,14 +31,15 @@ def init_driver_chrome():
|
|||||||
options = Options()
|
options = Options()
|
||||||
options.add_argument("--headless") # Run in headless mode
|
options.add_argument("--headless") # Run in headless mode
|
||||||
options.add_argument("--no-sandbox")
|
options.add_argument("--no-sandbox")
|
||||||
|
options.add_argument('--user-data-dir=/home/pythagodzilla/.config/chromium/Default')
|
||||||
# options.add_experimental_option("detach", True)
|
# options.add_experimental_option("detach", True)
|
||||||
driver = webdriver.Chrome(service=service, options=options)
|
driver = webdriver.Chrome(service=service, options=options)
|
||||||
driver.implicitly_wait(5) # Implicit wait for elements to load
|
driver.implicitly_wait(5) # Implicit wait for elements to load
|
||||||
return driver
|
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
|
import time
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
@ -48,8 +49,10 @@ def get_points(driver) -> None:
|
|||||||
driver.maximize_window()
|
driver.maximize_window()
|
||||||
|
|
||||||
cont = driver.find_elements(By.CLASS_NAME, "promo_cont") # 查找class:promo_cont。但对应多个可点击元素
|
cont = driver.find_elements(By.CLASS_NAME, "promo_cont") # 查找class:promo_cont。但对应多个可点击元素
|
||||||
|
|
||||||
for i in cont:
|
for i in cont:
|
||||||
if i.get_attribute('role') == 'banner' or i.get_attribute('id') == 'exclusive_promo_cont':
|
if i.get_attribute('role') == 'banner' or i.get_attribute('id') == 'exclusive_promo_cont':
|
||||||
i.click() # 点击所有符合元素
|
i.click() # 点击所有符合元素
|
||||||
|
|
||||||
time.sleep(10) # 等待页面完全加载。
|
|
||||||
|
time.sleep(10) # 等待页 面完全加载。
|
||||||
|
Loading…
x
Reference in New Issue
Block a user