今日內容:
一 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中安裝
- 安裝谷歌瀏覽器
...
使用方法:
from selenium import webdriver import time ''' 驅動瀏覽器的兩種方式 ''' # 第一種直接去Script文件夾中查找驅動 driver = webdriver.Chrome() time.sleep(5) driver.close() # 第二種填寫驅動路徑 # webdriver.Chrome( # r'C:\Users\Dell\Downloads\chromedriver.exe')
總結:因爲教室的緣由今日學習的內容較少。因此沒有總結,可是仍是完成了安裝的基本操做!python