![](/img/trans.png)
[英]How can i get car names by using driver.find_elements(By.XPATH,'') with Python Selenium
[英]How can i get http response using Selenium driver with PYTHON?
我正在嘗試使用 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)}
它顯示錯誤:
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)
我遇到了同樣的問題,我想用這種方法獲取日志,但是在那之后,我的日志不是完整的網絡日志。 根據我的經驗,我建議像這樣使用Browsermob
通過使用這種方法,您可以獲得一個Har文件,它是一個 JSON 格式的存檔文件,其中包含 web 瀏覽器與站點交互的日志。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.