【发布时间】:2020-12-08 09:24:42
【问题描述】:
导入操作系统
os.system('chrome sololearn')
#Chrome 搜索sololearn/ #我想让Chrome搜索sololearn
【问题讨论】:
-
请阅读How to Ask 并尝试给我们一个更易于理解的问题。
标签: python import operating-system
导入操作系统
os.system('chrome sololearn')
#Chrome 搜索sololearn/ #我想让Chrome搜索sololearn
【问题讨论】:
标签: python import operating-system
您可以使用 Selenium 自动执行 Google 搜索 首先在你的 idle 或 pycharm 中安装 selenium 硒
pip install selenium
安装
Chrome 驱动程序
从here下载chrome浏览器(选择你系统的版本) 下载后解压,然后将文件复制到脚本文件夹中。
from selenium import webdriver
# Taking input from user
search_string = input("Input the URL or string you want to search for:")
# This is done to structure the string
search_string = search_string.replace(' ', '+')
# Assigning the browser variable with chromedriver of Chrome.
browser = webdriver.Chrome('chromedriver')
for i in range(1):
matched_elements = browser.get("https://www.google.com/search?q=" +
search_string + "&start=" + str(i))
【讨论】: