首页 > 解决方案 > 带有硒/铬/铬驱动程序的空白页

问题描述

我在 python3 中使用网络抓取,直到昨天它运行正常......在 sudo apt update 和 upgrade 脚本停止在我的服务器上工作。我相信它与一些版本不兼容,在加载网页时,甚至没有延迟,立即响应页面空白。按照我安装的版本,根据它们兼容的软件网站。

python3-selenium 3.8.0+dfsg1-3
chromium-browser 80.0.3987.87-0ubuntu0.18.04.1).
chromedriver 80.0.3987.16
python3-pyvirtualdisplay 0.2.1-2
Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-88-generic x86_64)

我的代码:

import time
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
import selenium.webdriver.chrome.service as service
from pyvirtualdisplay import Display
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import csv


chromedriver_path = "/usr/bin/chromedriver"
chromium_path = "/usr/bin/chromium-browser"
service = service.Service(chromedriver_path)
service.start()
capabilities = {'chrome.binary': chromium_path}
opts = Options()
opts.binary_location = chromium_path
display = Display(visible=0, size=(1366, 800))
display.start()
driver = webdriver.Chrome()
driver = webdriver.Chrome(chrome_options=opts)
driver.get('WEBSITE')

“错误”:

>>> driver.get('URL')
>>>
>>> print (driver)
<selenium.webdriver.chrome.webdriver.WebDriver (session="10b0f9891b06979f90497b7bd0ef031c")>
>>> images = driver.find_elements_by_id("imgcap")
>>> print (images)
[]

以前,它返回一个图像链接。

标签: python-3.xseleniumwebdriverchromium

解决方案


推荐阅读