使用selenium自动操作浏览器百度搜索指定的词条

Posted haoqirui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用selenium自动操作浏览器百度搜索指定的词条相关的知识,希望对你有一定的参考价值。

from selenium import webdriver

# chrome驱动放在当前文件夹
myweb = webdriver.Chrome(executable_path="./chromedriver")
url = "https://www.baidu.com"
# 打开百度
myweb.get(url=url)

# 定位到text的文本框
text = myweb.find_element_by_id("kw")

# 搜索词条
text.send_keys("人民币")

# 定位到搜索键
button = myweb.find_element_by_id("su")
# 点击搜索键
button.click()

以上是关于使用selenium自动操作浏览器百度搜索指定的词条的主要内容,如果未能解决你的问题,请参考以下文章