我尝试使用selenium webdriver获取页面的url HTTP响应。谁能帮我一下吗。在
我正在尝试使用我在别处找到的一些代码
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)}
显示错误:
^{pr2}$
我也遇到了同样的问题,我想用这种方法获取日志,但是在那之后,我的日志就不是一个完整的网络日志了。根据我的经验,我建议使用Browsermob像this
使用这种方法,您可以得到一个Har文件,它是一个JSON格式的归档文件,其中包含web浏览器与站点交互的日志。在
相关问题 更多 >
编程相关推荐