【发布时间】:2021-11-11 02:29:56
【问题描述】:
我正在尝试在特定时间使用 selenium 打开网页,但它不起作用。这是我的代码:
import time
from selenium import webdriver
from datetime import datetime
while True:
PATH = "chromedriver.exe"
driver = webdriver.Chrome(PATH)
ct = datetime.now().strftime("%H:%M")
if ct == 8:55:
driver.get("https://webpage.com/")
else:
print("Waiting for time to be 8:55...")
time.sleep(100)
预期:如果当前时间是 8:55,则必须打开网页“https://webpage.com/”,否则应打印文本“Waiting for the time to be 8:55”和睡眠 100 秒。
实际结果:代码返回这些错误:
Expected expression. Pylance [11, 19]
Type annotation not supported for this type of expression. Pylance [11, 19]
Unexpected indentation. Pylance [12, 9]
Unindent not expected. Pylance [15, 24]
Expected expression. Pylance [15, 24]
Statements must be separated by newlines or semicolons. Pylance [15, 24]
我使用 Visual Studio Code 作为我的 IDE,并且我安装了 selenium。
【问题讨论】:
标签: python selenium if-statement pylance