day04 selenium请求库

今日内容:
一 Selenium请求库



一 Selenium请求库
1.什么是selenium?
selenium是一个自动测试工具,它可以帮我通过代码
去实现驱动浏览器自动执行相应的操作。
所以我们也可以用它来做爬虫。

2.为什么要使用selenium?
主要使用selenium的目的是为了跳过登录验证。

3.安装与使用
- 下载驱动器:
http://npm.taobao.org/mirrors/chromedriver/2.38/

- 下载selenium请求库
- 修改下载源为清华源
- D:\python36\Lib\site-packages\pip\models\index.py
- PyPI = Index('https://pypi.tuna.tsinghua.edu.cn/simple')


- pip3 install selenium 或 settings中安装


- 安装谷歌浏览器
...
     selenium库基础调用
 1 from selenium import  webdriver
 2 import time
 3 
 4 '''
 5 驱动浏览器的俩种方式
 6 '''
 7 
 8 # 第一种直接去 Scripes 文件中查找驱动
 9 # webdriver.Chrome()
10 # 第二种填写驱动路径
11 driver = webdriver.Chrome(
12     r'F:\python\Scripts\chromedriver.exe'
13 )
14 time.sleep(5)
15 driver.close()


猜你喜欢

转载自www.cnblogs.com/cooperstar/p/11100083.html