Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
922 B
3
Indexable
Never
from datetime import datetime, timedelta
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service 
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome(ChromeDriverManager().install())
current_date = datetime.now()
for day in range(1, 501):
    driver.get("https://www.thantai1.net/so-ket-qua")

    try:
        date_string = current_date.strftime("%Y-%m-%d")
        date_input = driver.find_element(By.XPATH, '//*[@id="end"]')
        date_input.clear()
        date_input.send_keys(date_string)
        print(f"Đã truy cập trang web cho ngày {date_string}")
    
    except Exception as e:
        print(f"Lỗi trong quá trình truy cập trang web cho ngày {date_string}: {str(e)}")
    current_date -= timedelta(days=1)
driver.quit()