1. 打開(kāi)cmd ,輸入python之后直接輸入下面的版本
from selenium import webdriver # 從selenium導(dǎo)入webdriver
driver = webdriver.Chrome() # Optional argument, if not specified will search path.
driver.get('https://www.baidu.com') # 獲取百度頁(yè)面
?inputElement = driver.find_element_by_id('kw') #獲取輸入框
searchButton = driver.find_element_by_id('su') #獲取搜索按鈕
?inputElement.send_keys("Python") #輸入框輸入"Python"
searchButton.click() #搜索
driver.close()
2. 直接把代碼保存成.py文件, cmd下執(zhí)行
cmd到文件存儲(chǔ)的位置
python
輸入文件名