seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.45k stars 908 forks source link

HTTP Request Interception #2871

Closed namename-123 closed 1 week ago

namename-123 commented 1 week ago

I'm trying the code below and it keeps giving me the following error: No module named 'blinker._saferef' How can I fix it? Also it would be great if I could change the request's parameters/headers, like changing a certain header before continuing the request like in playwright/puppeteer.



def intercept_response(request, response):
    print(request.headers)

driver = Driver(wire=True)
try:
    driver.response_interceptor = intercept_response
    driver.get("https://wikipedia.org")
finally:
    driver.quit()```
mdmintz commented 1 week ago

Run pip install blinker==1.7.0 to downgrade blinker for selenium-wire, or upgrade to a newer version of seleniumbase, which will automatically install the correct version of blinker at runtime when using Wire Mode.

(selenium-wire is an external library used by seleniumbase in Wire Mode)