【问题标题】:How to browse using python? [closed]如何使用python浏览? [关闭]
【发布时间】:2020-12-08 09:24:42
【问题描述】:

导入操作系统

os.system('chrome sololearn')

#Chrome 搜索sololearn/ #我想让Chrome搜索sololearn

【问题讨论】:

  • 请阅读How to Ask 并尝试给我们一个更易于理解的问题。

标签: python import operating-system


【解决方案1】:

您可以使用 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)) 

【讨论】:

    猜你喜欢
    • 2010-11-20
    • 1970-01-01
    • 2021-07-23
    • 2011-12-13
    • 1970-01-01
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多