如何使用带PYTHON的Selenium驱动程序获得http响应?
我正在尝试使用SeleniumWebDriver获取页面的url的HTTP响应。谁能帮我一下吗 我正在尝试使用我在别处找到的一些代码如何使用带PYTHON的Selenium驱动程序获得http响应?,python,selenium,http,selenium-webdriver,httpresponse,Python,Selenium,Http,Selenium Webdriver,Httpresponse,我正在尝试使用SeleniumWebDriver获取页面的url的HTTP响应。谁能帮我一下吗 我正在尝试使用我在别处找到的一些代码 from selenium import webdriver import logging from selenium.webdriver.common.desired_capabilities import DesiredCapabilities # enable browser logging d = DesiredCapabilities.CHROME
from selenium import webdriver
import logging
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
# enable browser logging
d = DesiredCapabilities.CHROME
d['loggingPrefs'] = {'performance': 'ALL'}
driver = webdriver.Chrome(executable_path="C:\\Users\\Admin\\PythonFiles\\chromedriver.exe",
service_args=["--verbose", "--log-path=D:\\selenium.log"],
desired_capabilities=d)
driver.get('https://www.atg.party')
print(driver.title)
print(driver.page_source)
performance_log = driver.get_log('performance')
print(str(performance_log).strip('[]'))
for entry in driver.get_log('performance'):
print(entry)}
它显示了一个错误:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: log type 'performance' not found
(Session info: chrome=77.0.3865.120)
我也遇到了同样的问题,我想用这种方法获取日志,但在那之后,我的日志不是一个完整的网络日志。根据我的经验,我建议使用Browsermoblike
使用此方法,您可以拥有一个Har文件,该文件是一个JSON格式的归档文件,其中包含web浏览器与站点交互的日志 我也遇到了同样的问题,我想用这种方法获取日志,但之后,我的日志就不是完整的网络日志了。根据我的经验,我建议使用Browsermoblike 使用此方法,您可以拥有一个Har文件,该文件是一个JSON格式的归档文件,其中包含web浏览器与站点交互的日志 看起来像复制品?看起来像复制品?