selenium linux 平台获取页面为空
在linux下获取的网页源码为一下内容
<html xmlns="http://www.w3.org/1999/xhtml"><head>head><body>body>html>
解决方案
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
url = 'https://10.11.227.21/tmui/'
driver.get(url + "login.jsp")
html_source = driver.page_source
print(html_source)
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
capabilities = DesiredCapabilities.CHROME.copy()
capabilities['acceptSslCerts'] = True
capabilities['acceptInsecureCerts'] = True
driver = webdriver.Chrome(chrome_options = chrome_options,executable_path='your path',desired_capabilities=capabilities)
driver.get("yourWebsite")