selenium---输入内容后搜索

from time import sleep
from selenium import webdriver

br = webdriver.Chrome()

url = "https://www.tmall.com"
br.get(url)

button = br.find_element_by_xpath('//*[@id="mallSearch"]/form/fieldset/div/button')
input = br.find_element_by_xpath('//*[@id="mq"]')
input.clear()
input.send_keys("iphone")
button.click()

sleep(3)
input = br.find_element_by_xpath('//*[@id="mq"]')
button = br.find_element_by_xpath('//*[@id="mallSearch"]/form/fieldset/div/button')
input.clear()
input.send_keys('华为')
button.click()
sleep(3)
br.close()
原文地址:https://www.cnblogs.com/brady-wang/p/12463458.html