如何在 selenium python 中从网络获取 javascript 和 css 请求的状态

How to fetch status of javascript and css requests from network in selenium python

我想获取我网站 https://lifesciences.cactusglobal.com/ 的特定 javascript 和 css 网络请求的状态。这些网络请求可以在 chrome 网络中看到。我想打印下面附上的请求 url 及其响应 code.Screenshot 以供参考,检查下划线的请求:

我尝试使用包 selenium-wire

driver.get('https://www.google.com')

for request in driver.requests:
    if request.response:
        print(
            request.url,
            request.response.status_code,
            request.response.headers['Content-Type']
        )

但它 returns 仅响应 url 的 headers 输入而不是网络请求。有没有其他方法可以遍历 selenium python?

中的网络请求

谢谢

输出一团糟,但尝试像这样获取网络请求,它似乎对我有用:

driver.get('https://lifesciences.cactusglobal.com/')
time.sleep(3)
test = driver.execute_script("var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;")

for item in test:
  print(item)

非常感谢您的支持。我找到了一个非常适合我要求的解决方案。
参考这些链接:
https://gist.github.com/rengler33/f8b9d3f26a518c08a414f6f86109863c https://www.rkengler.com/how-to-capture-network-traffic-when-scraping-with-selenium-and-python/
还找到了一个简单的方法包(虽然没有坚持下去)- pip install selenium-wire