import time
from selenium import webdriver ##驱动浏览器
from selenium.webdriver.support.wait import WebDriverWait
browser = webdriver.Chrome() ##调用Chrome的驱动,生产一个浏览器对象
wait = WebDriverWait(browser,10) ##设置selenium等待浏览器加载完毕的最大时间
try:
# browser.get("https://www.baidu.com/")
url = "https://www.baidu.com/"
browser.get(url)
baiduInput = browser.find_element_by_id("kw")
baiduInput.send_keys("李知恩")
baiduBtn = browser.find_element_by_id("su")
baiduBtn.click()
print(browser.page_source)
print(browser.current_url)
finally:
time.sleep(2)
browser.close()