应用Webdriver,实现自动化
1 #coding:gbk 2 from selenium import webdriver 3 import os 4 5 from selenium.webdriver.support.ui import Select 6 base_url ="https://www.baidu.com" 7 chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" #调用chrome安装文件夹下的驱动文件(驱动需要下载) 8 os.environ["webdriver.chrome.driver"] = chromedriver 9 driver = webdriver.Chrome(chromedriver) 10 def baidu(url): 11 driver.get(url) 12 driver.find_element_by_id("kw").send_keys(u"涛哥爱吃面") 13 driver.find_element_by_id("su").click() 14 15 baidu(base_url)
时间: 2024-12-16 03:33:48