简体   繁体   中英

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.

Any help is appreciated, thanks in advance.

You can do this using 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']
        )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM