[Python] 纯文本查看 复制代码 from time import sleep
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver= webdriver.Edge() # 需要 下载 对应浏览器 驱动到 python 安装目录
driver.get("http://www.baidu.com") # 刷新网址
for i in range(10000): # 刷新次数
driver.refresh() # 刷新网页
sleep(5) # 30秒一次
try:
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "kw")))
print("搜索输入框已加载")
except Exception:
current_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
with open("Err_Date.log", 'a', encoding='utf-8') as f:
f.write(f"页面未正常打开,时间:{current_time}\n") |