python模块 selenium

selenium介绍

selenium 模块让 Python 直接控制浏览器,实际点击链接,填写登录信息,几乎就像是有一个人类用户在与页面交互。与 Requests 和 Beautiful Soup 相比,Selenium允许你用高级得多的方式与网页交互.

安装

pip3 install selenium
from selenium import webdriver

下载相应浏览器的驱动程序,这里以Chrome为例

1. 查看Chrome浏览器的版本
2. http://chromedriver.storage.googleapis.com/index.html 此处下载驱动程序

使用selenium模块

from selenium import webdriver
""""下面的驱动程序位置可以写入到环境变量,就不用写这么长了""""
browser = webdriver.Chrome(executable_path="C:\\Users\\15454\Desktop\\chromedriver_win32\\chromedriver.exe")
browser.get('http://www.baidu.com')
posted @ 2021-11-23 14:25  少林寺驻峨眉山大神父  阅读(32)  评论(0编辑  收藏  举报