简体   繁体   English

"如何使用 Python 从网络选项卡的特定请求的“请求标头”中获取信息?"

[英]How can I fetch info from the "Request Headers" of a specific request from the network tab using Python?

I'm trying to fetch a specific<\/strong><\/em> value of a specific<\/strong><\/em> request from the network tab using python.我正在尝试使用 python 从网络选项卡中获取特定<\/strong><\/em>请求的特定<\/strong><\/em>值。

For example, let's say I want to fetch the value stored in cookie<\/strong><\/em> from one of the get<\/strong><\/em> requests:例如,假设我想从其中一个get<\/strong><\/em>请求中获取存储在cookie<\/strong><\/em>中的值:

When I open the network tab<\/strong> I get these Fetch\/XHR requests, I select the get<\/strong><\/em> request: Image explanation<\/a>当我打开网络选项卡<\/strong>时,我收到这些 Fetch\/XHR 请求,我选择了获取<\/strong><\/em>请求:图片说明<\/a>

After I click on the get<\/strong><\/em> request and I scroll down to the " Request Headers<\/em> " list I get the following values, I want to fetch the value of " cookie<\/strong><\/em> ": Image explanation<\/a>单击获取<\/strong><\/em>请求并向下滚动到“请求标头<\/em>”列表后,我得到以下值,我想获取“ cookie<\/strong><\/em> ”的值:图片说明<\/a>

How can I get this specific value using python and print it in the console?如何使用 python 获取这个特定值并在控制台中打印它? Any help is appreciated, thanks in advance.任何帮助表示赞赏,在此先感谢。

"

You can do this using seleniumwire:您可以使用 seleniumwire 执行此操作:

from seleniumwire import webdriver  # Import from seleniumwire

# Create a new instance of the chrome web driver
driver = webdriver.Chrome()
url = "https://www.google.com/"  
driver.get(url)

# Access requests via the `requests` attribute
for request in driver.requests:
    if request.response:
    # here you need to filter the name of the url request you want
    # if "name_of_the_url_in_header" in request.url
        print(
            request.url
            request.headers['cookie']
        )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python 保存来自网站的所有网络流量(包括请求和响应标头) - How to save all the network traffic (both request and response headers) from a website using python 如何根据从Firebug工具获得的请求标头使用python中的请求模块登录到此站点? - How can i login to this site with requests module in python based on the request headers i got from firebug tool? 如何使用 python 获取客户端在请求标头中插入的新参数? - How to fetch a new param inserted by client in request headers using python? 在Python中,如何从动态加载的网站请求特定数据? - In Python, how can I request specific data from a dynamically loaded website? Python request.headers与我在Chrome中看到的有所不同 - Python request.headers differs from what I see in Chrome 使用Python从单个请求获取HTML和标头 - Get html and headers from single request using Python 如何使用公式作为参考,使用 Python 和 Pandas(或类似的东西)从另一个 Excel 选项卡中获取数据 - How can I fetch data from another Excel tab using a formula as reference using Python and Pandas (or something like) 无法从python请求响应中获取数据 - Can't fetch data from python request response 如何使用 Python Scrapy 从本网站获取信息? - How can I obtain info from this website using Python Scrapy? 如何使用 Python 从 TFS REST API 获取信息? - How to fetch info from TFS REST API using Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM