     [Answers](https://scrapfly.io/blog)   /  [selenium](https://scrapfly.io/blog/tag/selenium)   /  [How to capture background requests and responses in Selenium?](https://scrapfly.io/blog/answers/how-to-capture-xhr-requests-selenium)   # How to capture background requests and responses in Selenium?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Jun 30, 2023 1 min read [\#selenium](https://scrapfly.io/blog/tag/selenium) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-capture-xhr-requests-selenium "Share on LinkedIn")    

 

 

Selenium doesn't have a request interception functionality out of the box but we can enable it using `selenium-wire` extension.

Capturing background requestscan be an important step of a web scraping process and this area is where Selenium is lacking, so let's take a look how to use Selenium extension - `selenium-wire` to implement this vital feature.

To start `selenium-wire` can be installed using `pip install selenium-wire` command. Then all requests are captured automatically and stored in `driver.request` variable:

python```python
from seleniumwire import webdriver  # Import from seleniumwire
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait


driver = webdriver.Chrome()
driver.get('https://web-scraping.dev/product/1')
# wait for element to appear and click it to trigger background requests
element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load-more-reviews')))
element.click()
# 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'],
            request.response.body,
        )
driver.quit()
```



Often these background requests can contain important dynamic data and using this capturing technique is an easy way to scrape it. For more see our [web scraping background requests](https://scrapfly.io/blog/posts/web-scraping-background-requests-with-headless-browsers-and-python) guide.



 

    



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

## Explore this Article with AI

 [ ChatGPT ](https://chat.openai.com/?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-capture-xhr-requests-selenium) [ Gemini ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-capture-xhr-requests-selenium) [ Grok ](https://x.com/i/grok?text=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-capture-xhr-requests-selenium) [ Perplexity ](https://www.perplexity.ai/search/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-capture-xhr-requests-selenium) [ Claude ](https://claude.ai/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-capture-xhr-requests-selenium) 



 ## Related Articles

 [  

 python headless-browser 

### Selenium Wire Tutorial: Intercept Background Requests

In this guide, we'll explore web scraping with Selenium Wire. We'll define what it is, how to install it, and how to use...

 

 ](https://scrapfly.io/blog/posts/how-to-intercept-background-requests-with-selenium-wire) [  

 python headless-browser 

### Web Scraping Background Requests with Headless Browsers

In this tutorial we'll be taking a look at a rather new and popular web scraping technique - capturing background reques...

 

 ](https://scrapfly.io/blog/posts/web-scraping-background-requests-with-headless-browsers-and-python) [  

 python headless-browser 

### Web Scraping with Selenium and Python

Introduction to web scraping dynamic javascript powered websites and web apps using Selenium browser automation library ...

 

 ](https://scrapfly.io/blog/posts/web-scraping-with-selenium-and-python) 

  ## Related Questions

- [ Q How to capture background requests and responses in Playwright? ](https://scrapfly.io/blog/answers/how-to-capture-xhr-requests-playwright)
- [ Q How to capture background requests and responses in Puppeteer? ](https://scrapfly.io/blog/answers/how-to-capture-xhr-requests-puppeteer)
- [ Q Selenium: geckodriver executable needs to be in PATH? ](https://scrapfly.io/blog/answers/selenium-geckodriver-in-path)
- [ Q Selenium: chromedriver executable needs to be in PATH? ](https://scrapfly.io/blog/answers/selenium-chromedriver-in-path)
 
  



   



 Run headless browsers at scale, **1,000 free credits** [Start Free](https://scrapfly.io/register)