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()

 

posted @ 2020-03-11 16:54  brady-wang  阅读(900)  评论(0)    收藏  举报