【发布时间】:2019-04-30 12:06:51
【问题描述】:
设置:
- 硒:3.141.0
- python:3.6.7
- heroku-stack:heroku-18
- headless-chrome:已安装 v71.0.3578.80 buildpack
- chromedriver:已安装 v2.44.609551 buildpack
在 heroku 中使用 selenium 时出现此错误:
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
我用谷歌搜索但没有运气。错误发生在这段代码的最后一行。
代码
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
UA = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36' \
'(KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
DRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = '/app/.apt/usr/bin/google-chrome'
chrome_options.add_argument(f'--user-agent={UA}')
chrome_options.add_argument(f'--proxy-server=http://my_private_proxy.com:my_port')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome = webdriver.Chrome(executable_path=DRIVER_PATH, options=options)
【问题讨论】:
标签: python-3.x selenium heroku selenium-chromedriver buildpack