# Wait > Source: https://scrape.do/documentation/headless-browser/wait/ Configure wait times and page load behavior Control when the headless browser considers a page fully loaded and ready for data extraction. These parameters help you handle dynamic content, AJAX requests, and ensure all necessary elements have rendered before scraping. ## Wait Until Our headless browser system uses `waitUntil=domcontentloaded` during navigation by default. However, in some cases, you may need to change it. With this parameter, you can adjust this behavior and ensure that the page loads correctly according to your needs. The `waitUntil` parameter accepts the following values: `domcontentloaded`, `networkidle0`, `networkidle2`, and `load`: - `domcontentloaded` waits for the DOMContentLoaded event to fire, which occurs when the initial HTML document has been completely loaded and parsed. - `networkidle0` waits until there are no more than 0 network connections for at least 500 ms. - `networkidle2` waits until there are no more than 2 network connections for at least 500 ms. - `load` waits for the window.load event to fire, which occurs when all page resources (including images, stylesheets, and scripts) have finished loading. This option is particularly useful for ensuring that scroll-triggered images and other dynamic content are fully loaded. **cURL (API mode)** ```bash curl --location --request GET 'https://api.scrape.do/?token=YOUR_TOKEN&url=https://httpbin.co/anything&waitUntil=domcontentloaded&render=true' ``` **Python (API mode)** ```python import requests import urllib.parse token = "YOUR_TOKEN" targetUrl = "https://httpbin.co/anything" opts = "domcontentloaded" encoded_url = urllib.parse.quote(targetUrl) url = "http://api.scrape.do/?token={}&url={}&waitUntil={}&render=true".format(token, encoded_url,opts) response = requests.request("GET", url) print(response.text) ``` **Node.js (API mode)** ```javascript const axios = require('axios'); const token = "YOUR_TOKEN"; const targetUrl = "https://httpbin.co/anything" const encodedUrl = encodeURIComponent(targetUrl); const opts = "domcontentloaded"; const config = { 'method': 'GET', 'url': `https://api.scrape.do/?token=${token}&url=${encodedUrl}&waitUntil=${opts}&render=true`, 'headers': {} }; axios(config) .then(function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); ``` **cURL (Proxy mode)** ```bash curl -k -x "http://YOUR_TOKEN:waitUntil=domcontentloaded&render=true@proxy.scrape.do:8080" 'https://httpbin.co/anything' -v ``` **Python (Proxy mode)** ```python import requests import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) url = "https://httpbin.co/anything" token = "YOUR_TOKEN" proxyModeUrl = "http://{}:waitUntil=domcontentloaded&render=true@proxy.scrape.do:8080".format(token) proxies = { "http": proxyModeUrl, "https": proxyModeUrl, } response = requests.request("GET", url, proxies=proxies, verify=False) print(response.text) ``` **Node.js (Proxy mode)** ```javascript const axios = require('axios'); const token = "YOUR_TOKEN"; const targetUrl = "https://httpbin.co/anything"; axios({ method:"GET", url:targetUrl, proxy: { protocol:'http', host: 'proxy.scrape.do', port: 8080, auth: { username: token, password: 'waitUntil=domcontentloaded&render=true' } } }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error.message); }); ``` *(Go, Ruby, Java, C#, PHP examples are also available on the HTML version.)* --- ## Custom Wait With the JS Render infrastructure, you may want to wait for a certain period of time to ensure that all content is loaded correctly on the web page you're accessing. This parameter accepts values between 0 and 35000 milliseconds. **cURL (API mode)** ```bash curl --location --request GET 'https://api.scrape.do/?token=YOUR_TOKEN&url=https://httpbin.co/anything&customWait=1000&render=true' ``` **Python (API mode)** ```python import requests import urllib.parse token = "YOUR_TOKEN" targetUrl = urllib.parse.quote("https://httpbin.co/anything") customWait = "1000" render = "true" url = "http://api.scrape.do/?token={}&url={}&customWait={}&render={}".format(token, targetUrl,customWait,render) response = requests.request("GET", url) print(response.text) ``` **Node.js (API mode)** ```javascript const axios = require('axios'); const token = "YOUR_TOKEN"; const targetUrl = encodeURIComponent("https://httpbin.co/anything"); const customWait = "1000"; const render = true; const config = { 'method': 'GET', 'url': `https://api.scrape.do/?token=${token}&url=${targetUrl}&customWait=${customWait}&render=${render}`, 'headers': {} }; axios(config) .then(function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); ``` **cURL (Proxy mode)** ```bash curl -k -x "http://YOUR_TOKEN:render=true&customWait=1000@proxy.scrape.do:8080" 'https://httpbin.co/anything' -v ``` **Python (Proxy mode)** ```python import requests import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) url = "https://httpbin.co/anything" token = "YOUR_TOKEN" proxyModeUrl = "http://{}:render=true&customWait=1000@proxy.scrape.do:8080".format(token) proxies = { "http": proxyModeUrl, "https": proxyModeUrl, } response = requests.request("GET", url, proxies=proxies, verify=False) print(response.text) ``` **Node.js (Proxy mode)** ```javascript const axios = require('axios'); const token = "YOUR_TOKEN"; const targetUrl = "https://httpbin.co/anything"; axios({ method:"GET", url:targetUrl, proxy: { protocol:'http', host: 'proxy.scrape.do', port: 8080, auth: { username: token, password: 'render=true&customWait=1000' } }, }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error.message); }); ``` *(Go, Ruby, Java, C#, PHP examples are also available on the HTML version.)* --- ## Wait CSS Selector With the JS Render infrastructure, the data you expect on the web page can be returned via specific elements. We can wait for these elements to load using the `waitSelector` parameter and return the result once the relevant element is loaded. For example, you can wait for an element using `waitSelector=.element` or `waitSelector=#element-id`. The system waits for up to 10 seconds for the specified element to appear in the content. If the element does not appear, the response will be returned in its raw form. > [!NOTE] > `waitSelector` and `waitCSSSelector` are both accepted as parameter names and behave identically. You need to **URL-encode** the value in either case. ### Target Data in Browser ```html