linux系统下部署selenium做网页爬虫,可以顶几十上百个人工采集数据。
下面我就聊一聊怎么把selenium 程序部署到Linux 服务器上面 。
一、selenium
Selenium是一个用于Web应用程序测试的一个工具。Selenium测试直接运行在浏览器中,就像真正的用户在操作一样, 数据抓取用它来爬取一些js动态加载的数据非常方便快捷。
二、具体使用步骤
1、引入库
pip3 install selenium # 安装对应的库
代码如下
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options # 使用无头浏览器
from selenium.webdriver import ChromeOptions
chrome_options = Options()
options = ChromeOptions()
options.add_experimental_option(‘excludeSwitches’, [‘enable-automation’]) # =>去掉浏览器正在受到自动测试软件的控制
options.add_experimental_opt