静态网页可以requests和BeautifulSoup获取元素数据
但是要获取动态网页数据就需要使用selenium webdriver了
谨以此文记录一下我的爬虫步骤以及遇到的问题
from selenium import webdriver
import time
driver = webdriver.Chrome()
首先是使用 webdriver.Chrome()出现报错:
解决:下载与谷歌浏览器对应的chromedriver
地址:https://chromedriver.storage.googleapis.com/index.html
如果是76版本的chrome,下载
安装chromedriver:
- 打开Finder,然后使用command+shift+G,在弹出的目录中填写/usr/local
- 若/usr/local没有bin文件,找到上层的bin文件夹,复制到local
- 将解压的chromedriver移动到/usr/local/bin