Selenium4.0实现自动搜索功能
01.Selenium4.0实现搜索功能
1.安装Selenium及查看Selenium版本
pip install selenium
pip show selenium
from selenium import webdriver
from chromedriver_py import binary_path
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
#启动Chrome
svc = webdriver.ChromeService(executable_path=binary_path)
driver = webdriver.Chrome(service=svc)
#打开baidu网址
driver.get('http://www.baidu.com')
# 设置窗口大小
#driver.set_window_size(1920, 1080)
time.sleep(5)
a = driver.find_element(By.ID, "kw")
#输入搜索字符
a.send_keys("python")
a.send_keys(Keys.RETURN)
time.sleep(20)
driver.quit()
原文地址:https://blog.csdn.net/Yee_XU/article/details/142434668
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!