python+selenium 使用参数化来搜索关键字

# coding=utf-8
from selenium import webdriver
import time
#设置搜索的关键字
search_text=['python','chinese','text']

for text in search_text:
    driver=webdriver.Firefox(executable_path='/Users/silence/Downloads/geckodriver')
    driver.implicitly_wait(5)
    driver.get("http://www.baidu.com")
    driver.find_element_by_id('kw').send_keys(text)
    driver.find_element_by_id('su').click()
    time.sleep(5)
    driver.quit()

 

你可能感兴趣的:(python练习)