...mitmproxy返回https://www.198bona.com/xhtml空白面的问题?_百度知...
发布网友
发布时间:2024-10-11 03:16
我来回答
共1个回答
热心网友
时间:2024-10-11 09:29
from selenium import webdriver
from pyvirtualdisplay import Display
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
#_____________________基本设定___________________________CHROME_DRIVER_PATH = r'/usr/bin/chromedriver'
PROXY = "http://127.0.0.1:8080"
#_____________________启动参数___________________________
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument("window-size=1024,768")
options.add_argument("--no-sandbox")
#_____________________代理参数___________________________
desired_capabilities = options.to_capabilities()
desired_capabilities['acceptSslCerts'] = True
desired_capabilities['acceptInsecureCerts'] = True
desired_capabilities['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"noProxy": None,
"proxyType": "MANUAL",
"class": "org.openqa.selenium.Proxy",
"autodetect": False,
}
#_____________________启动浏览器___________________________driver = webdriver.Chrome( chrome_options=options,
executable_path=CHROME_DRIVER_PATH,
desired_capabilities = desired_capabilities,
)
for i in range(1): driver.get('https://www.iplocation.net')
contant = driver.page_source driver.save_screenshot('hello.png')
print(contant) driver.close() driver.quit()
mitmdump -p 8080