简体   繁体   中英

Get all XHR Requests of a Site in Python

I want to make a program in python that prints out all the xhr requests of a site.

aDict = {'randomfile.js?_=1581185731016': {'url': 'https://softwaresat.netlify.com/randomfile.js?_=1581185731016', 'method': 'GET', 'address': '104.248.60.43:443'}}

You can use the selenium-wire python module for getting all the xhr calls of a website which helped me for my projects.

from seleniumwire import webdriver  # Import from seleniumwire

# Create a new instance of the Chrome driver
driver = webdriver.Chrome()

# Go to the Google home page
driver.get('https://www.google.com')

# Access requests via the `requests` attribute
for request in driver.requests:
    if request.response:
        print(
            request.url
        )

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