原先的写法
el = web.find_element_by_xpath('//*[@id="changeCityBox"]/p[1]/a')
web.find_element_by_xpath('//*[@id="search_input"]').send_keys('python',Keys.ENTER)
li_list = web.find_elements_by_xpath('//*[@id="jobList"]/div[1]/div')
出现一下警告:
现在的写法:
el = web.find_element(By.XPATH,'//*[@id="changeCityBox"]/p[1]/a')
web.find_element(By.XPATH,'//*[@id="search_input"]').send_keys('python',Keys.ENTER)
li_list = web.find_elements(By.XPATH,'//*[@id="jobList"]/div[1]/div')
By需要提前导入:
from selenium.webdriver.common.by import By
亲测有效,无警告。