【发布时间】:2019-01-08 21:30:14
【问题描述】:
我正在寻找一种从关键字列表中输入 Google 研究的方法。
它将作为循环工作,循环 1 = "keyword1",循环 2 = "keyword2"...
这里是循环代码:
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
def main():
driver.get('https://www.google.com')
driver.find_element_by_xpath('//*[@id="tsf"]/div[2]/div/div[1]/div/div[1]/input').send_keys('keyword1')
driver.find_element_by_xpath('//*[@id="tsf"]/div[2]/div/div[1]/div/div[1]/input').send_keys(Keys.ENTER)
time.sleep(2)
main()
while True:
main()
【问题讨论】:
标签: python python-3.x selenium variables automation