>
铬:
sudo apt-get install chromium-browser
硒
pip install selenium
from selenium import webdriver
service_args = ['--verbose']
service_log_path = "{}/chromedriver.log".format('/projects/')
driver = webdriver.Chrome('/path/to/chromedriver', service_args=service_args, service_log_path=service_log_path)
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.13.307649 (bf55b442bb6b5c923249dd7870d6a107678bfbb6),platform=Linux 3.13.0-30-generic x86_64)
下面是我的日志文件:什么是开发工具问题?
[0.973][INFO]: COMMAND InitSession {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [ ],
"extensions": [ ]
},
"javascriptEnabled": true,
"platform": "ANY",
"version": ""
}
}
[0.980][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"show_welcome_page": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[0.982][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[0.988][INFO]: Launching chrome: /usr/bin/chromium-browser --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.Wgxcag/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12948 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.Fqyvg3 data:,
[0.991][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[0.999][WARNING]: PAC support disabled because there is no system implementation
[1.113][DEBUG]: DevTools request failed
[1.165][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.166][DEBUG]: DevTools request failed
[1.217][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.217][DEBUG]: DevTools request failed
[1.268][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.269][DEBUG]: DevTools request failed
[1.319][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.320][DEBUG]: DevTools request failed
[1.370][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.371][DEBUG]: DevTools request failed
[1.422][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.423][DEBUG]: DevTools request failed
[1.474][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.475][DEBUG]: DevTools request failed
[1.526][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.527][DEBUG]: DevTools request failed
[1.577][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.578][DEBUG]: DevTools request failed
[1:1:0123/165812:ERROR:image_metadata_extractor.cc(111)] Couldn't load libexif.
[1.629][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.630][DEBUG]: DevTools request failed
[6845:6845:0123/165812:ERROR:browser_main_loop.cc(209)] Gtk: cannot open display:
[1.680][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.681][DEBUG]: DevTools request failed
[1.731][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.735][DEBUG]: DevTools request failed
[1.786][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.787][DEBUG]: DevTools request failed
[1.837][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.838][DEBUG]: DevTools request failed
[1.889][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.891][DEBUG]: DevTools request failed
[1.942][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.944][DEBUG]: DevTools request failed
[1.995][DEBUG]: DevTools request: http://127.0.0.1:12948/json/version
[1.997][DEBUG]: DevTools request failed
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Chrome()
browser.get('http://www.google.com')
print browser.title
browser.quit()
display.stop()
另见:
除此之外,切换到phantomjs
也是一种选择:
from selenium import webdriver
browser = webdriver.PhantomJS()
browser.get('http://www.google.com')
print browser.title
browser.quit()
我在过去的一周里一直在处理这个问题,脑子里想不起来,所以我决定寻求帮助。我正在尝试使用Chromium 86构建在AWS Lambda中运行Selenium。我不断收到的错误消息如下: 以下是我的版本: 这是我的代码: 到目前为止我已经尝试过的事情: 尝试了各种运行时Python 3.6、3.7、3.8,但没有成功 尝试使用和不使用Lambda层。尝试使用Lambda逐层文件夹结构时相对简单: C
如果我直接在docker中运行google-chrome,它会显示如下: 系统:
我使用Selenium和PhantomJS开发了几个Python脚本。当我转向自动下载时,我切换到了(headed)Firefox(有效),然后是Chrome,有了headless选项,这样浏览器就不会在我面前打开了。 我的第一个脚本访问一个页面和几个HTML元素,与无头Chrome完美地工作。 第二个,然而,工作与头铬。如果我加上“无头”选项,它就不再起作用了。当我试图以headless模式打印
我正在尝试自动化电子邮件注册。当我手动操作时,它会工作,但当我用selenium打开网站时,它不会工作。它有我不能做的验证。有没有一种方法可以在不被检测的情况下打开(而不是控制,我使用pyautogui)一个网站? 我的代码:
如何让下载以无头模式启动?
我的场景是站点上的单击图标打开文件浏览器。是否可以将图像附加到打开的文件浏览器窗口。我的配置是Docker,水豚,硒驱动程序。我正在测试无头和无头浏览器(Chrome)