from selenium import webdriver
import time
driver = webdriver.Chrome()
url = 'https://www.sogou.com'
driver.get(url)
time.sleep(2)
searchInputBoxJS="document.getElementById('query').value='天天向上';" # js语句定位元素并输入内容,还未操作
searchButtonJS="document.getElementById('stb').click();" # js语句定位元素并点击,还未操作
driver.execute_script(searchInputBoxJS) # 执行js语句操作页面
driver.execute_script(searchButtonJS) # 执行js语句操作页面
time.sleep(2)
driver.quit()
Python selenium automates the js operation of the browser, when the ordinary api cannot operate the browser, the advanced api method can be used
Guess you like
Origin blog.csdn.net/weixin_44123630/article/details/113835517
Recommended
Ranking