Selenium Wire extends Selenium's Python bindings to give you access to the underlying requests made by the browser. You author your code in the same way as you do with Selenium, but you get extra APIs for inspecting requests and responses and making changes to them on the fly.
23 lines
751 B
Text
23 lines
751 B
Text
Selenium Wire extends Selenium's Python bindings to give you access to the
|
|
underlying requests made by the browser. You author your code in the same way as
|
|
you do with Selenium, but you get extra APIs for inspecting requests and
|
|
responses and making changes to them on the fly.
|
|
|
|
Simnple example:
|
|
|
|
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,
|
|
request.response.status_code,
|
|
request.response.headers['Content-Type']
|
|
)
|