1

With Selenium Wire, you can intercept your requests like this:

from seleniumwire import webdriver 

def intercept_response(request, response):
        print(request.headers)
    
driver = webdriver.Chrome()
driver.response_interceptor = intercept_response

This prints a continuous stream of data for every request you make.

I attempted to do the same thing with SeleniumBase, but it doesn't work. The following only prints a single GET request, but the linkedIn page that I am visiting should yield multiple GET requests.

from seleniumbase import Driver
driver = Driver(browser="chrome", pls="eager", agent=agent, proxy=proxy, headed=True, wire=True)

driver.get("https://www.linkedin.com")
for request in driver.requests:
    print(request.url)

1 Answer 1

1

If this is the selenium-wire version:

from seleniumwire import webdriver

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

driver = webdriver.Chrome()
driver.response_interceptor = intercept_response
driver.get("https://wikipedia.org")
driver.quit()

Then the SeleniumBase equivalent would be:

from seleniumbase import Driver

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

driver = Driver(wire=True)
driver.response_interceptor = intercept_response
driver.get("https://wikipedia.org")
driver.quit()
Sign up to request clarification or add additional context in comments.

2 Comments

Hey, big fan of your work. I tried the code above and it works beautifully, the problem I can now see is that I have driver = Driver(wire=True, proxy=proxy) Is there some way to have a proxy AND have the HTTP requests printed out?
I tried it, and it works using the sbase proxy command, which creates a local proxy server on 127.0.0.1:8899. Use Driver(wire=True, proxy="127.0.0.1:8899") to run on it. sbase proxy was recently added, and uses github.com/abhinavsingh/proxy.py for creating the local proxy server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.