本帖最后由 suchocolate 于 2021-8-31 15:10 编辑
执行js一般是定制自己想做的操作才用,一般页面提供的功能不需要。
百度搜索直接点击即可。
selenium使用看7.1节:https://github.com/Python3WebSpider/Python3WebSpiderfrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as expected
from selenium.webdriver.support.wait import WebDriverWait
url = 'https://www.baidu.com'
browser = webdriver.Firefox()
browser.get(url)
wait = WebDriverWait(browser, 10)
wait.until(expected.visibility_of_element_located((By.ID, 'kw')))
ipt = browser.find_element_by_id('kw')
ipt.send_keys('明朝那些事')
ipt.send_keys(Keys.ENTER)
|