ScreenshotNeo

BlogHow-to

How to Capture Screenshots of Indian Court Websites with Selenium

Capture an Indian court webpage as a PNG with Selenium. Learn how to wait for dynamic content, choose the right screenshot scope, and handle site-specific policies.

By the ScreenshotNeo team4 October 20269 min read

Selenium WebDriver can save the current browser window as a PNG with driver.save_screenshot("court-page.png"). Open the exact court-service page, wait until the content you need is visible, then capture it. For one result or order section, use an element screenshot instead. The ordinary screenshot call captures the current view; do not assume it captures an entire long page across browsers.

“Indian court websites” can mean many separate services and linked portals. Identify the exact target first, and check its current access terms. A screenshot is a visual record of a webpage, not an authenticated court document or a substitute for the official record.

1. Identify the exact court page and capture scope

The eCourts portal links to High Court services, High Court NJDG, District Court services, District Court NJDG, e-Filing, e-Pay, Virtual Courts, and other services. Linked external websites are maintained by their respective departments, so layout, selectors, behavior, and policies can vary. Choose the specific court and page before writing automation. The eCourts portal overview and its accessibility statement describe this distributed scope.

Capture need Selenium approach Limit to account for
Record what is currently visible in the browser driver.save_screenshot(path) Captures the current browsing context/window; not a guaranteed full-page image.
Record one order heading, result, or page region element.screenshot(path) Requires a reliable locator and a visible, rendered element.
Record a long page from top to bottom Use a browser-specific full-page method only after verifying it for the browser and version in use. The basic WebDriver screenshot API does not promise cross-browser full-page capture.

Selenium documents both window screenshot examples and element screenshots. A selector must be chosen for the actual portal; no single selector works across every court site.

2. Install Selenium and a browser

Use a supported Selenium 4 installation and a browser available in the environment where the script runs. Selenium Manager can manage drivers for common local setups when creating the driver this way. In locked-down or preconfigured environments, install and configure the browser and driver according to that environment’s setup.

python -m pip install selenium

Save the following as capture_court.py. Replace the example URL with the exact page you are authorized to access. Replace the sample heading selector with a locator that identifies the content you need on that page.

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

URL = "https://example.gov.in/"
OUTPUT = Path("court-page.png")

options = webdriver.ChromeOptions()
# For a server without a display, uncomment the next line:
# options.add_argument("--headless=new")

# Selenium's default page-load strategy is normal. It waits for the
# document's complete state, but page-specific content may load later.
driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1440, 1000)
    driver.get(URL)

    # Choose a locator that matches the target page. This illustrative
    # heading is not a universal court-site selector.
    WebDriverWait(driver, 30).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "main h1"))
    )

    if not driver.save_screenshot(str(OUTPUT)):
        raise RuntimeError("WebDriver did not save the screenshot")
    print(f"Saved {OUTPUT.resolve()}")
finally:
    driver.quit()

The official Selenium Python API describes save_screenshot as saving the current window as a PNG and returning whether it succeeded. See the Python WebDriver API reference.

3. Wait for the page state that matters

A completed document load does not mean every result, order detail, or script-rendered component is ready. Selenium’s default page-load strategy waits for the document’s complete state; the official options guide notes that dynamic applications can continue loading after that. Prefer a wait for the actual target content over a fixed sleep.

  • Use an explicit wait: wait for a result row, order heading, or other relevant element to become visible.
  • Handle page-specific transitions: if a search form must be submitted, wait for the resulting content or URL change after submission.
  • Use a delay only when necessary: a short fixed delay can accommodate a known delayed rendering step, but it adds time and can still be too short.
  • Consider other page-load strategies deliberately: eager waits for DOM content loaded; none does not wait for page loading. Both require your own adequate waits to avoid capturing too early.

See Selenium’s browser options and page-load strategy documentation. Avoid polling or retrying aggressively against a court service; follow that site’s access rules.

4. Capture a specific element

When the page contains a stable, identifiable target, an element screenshot can avoid unrelated navigation or surrounding content. The example below waits for an illustrative result element, scrolls it into view, and saves it as PNG:

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

URL = "https://example.gov.in/"
OUTPUT = Path("court-result.png")

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
try:
    driver.get(URL)
    result = WebDriverWait(driver, 30).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "#case-result"))
    )
    driver.execute_script(
        "arguments[0].scrollIntoView({block: 'center'});", result
    )
    result.screenshot(str(OUTPUT))
    print(f"Saved {OUTPUT.resolve()}")
finally:
    driver.quit()

#case-result is only an example. Inspect the target page and use a selector that identifies the required element there. If the desired content is inside a frame, switch into the correct frame before locating it; if it is in a new window, switch to that window first.

5. Save screenshots from cURL, Python, and Node.js

If a browser session is not required and the target can be fetched by a screenshot API, these examples capture the same page with ScreenshotNeo. The endpoint returns an image or PDF according to the requested output and options; the simple examples save the response as WebP. Read the ScreenshotNeo API documentation for authentication and available parameters.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://example.gov.in/ \
  -o court-page.webp

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={
        "access_key": "YOUR_API_KEY",
        "url": "https://example.gov.in/",
    },
    timeout=90,
)
r.raise_for_status()
with open("court-page.webp", "wb") as f:
    f.write(r.content)

Node.js

const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.gov.in/',
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('court-page.webp', bytes));

6. Handle Indian court site terms and screenshot use

Check the terms and policies of the exact site before automating access, and respect access controls. The central eCourts terms do not establish blanket permission for automated access to every linked court website or a universal rate limit. If the target’s rules are unclear, contact its administrator. The eCourts terms also state that linked external sites follow the policies of their owners or sponsors.

A screenshot should be treated as a visual capture of a webpage, not as an authenticated order, legal record, or substitute for verification with the relevant authority. The eCourts terms say displayed documents and information are for reference and do not purport to be legal documents; the portal disclaimer says online information is not meant for legal evidence and asks users to cross-check against relevant authorities or records.

If you republish a screenshot, review the page contents and rights first. The eCourts copyright policy calls for prominent source acknowledgement when reproducing site content and notes that third-party copyrighted material may require separate permission. Check the target site and included material, since policies may differ.

7. Troubleshooting

Symptom Likely cause Fix
The screenshot is blank or missing the case result The page or dynamic content was not ready when capture ran. Wait for a visible, page-specific result element. Confirm that the script reached the expected page and that the result exists before saving.
TimeoutException while waiting The selector does not match this portal, the content is absent, or access led to an interstitial or error page. Inspect the actual page and selector in a browser. Confirm the URL, target state, and whether the site permits the requested access.
NoSuchElementException The locator was used before rendering, is incorrect, or the element belongs to a frame. Use an explicit wait, validate the selector on the exact page, and switch to the relevant frame if needed.
SessionNotCreatedException or browser startup failure Browser installation, driver configuration, or runtime environment is incompatible or unavailable. Check the installed browser and Selenium setup. In a headless server, configure headless mode and ensure required browser dependencies are present.
PNG exists but shows only part of a long page The standard screenshot captured the current view rather than a verified full-page image. Capture the relevant element or use a browser-specific full-page technique verified for your browser and version.
Element screenshot fails or clips the target The element is not visible, is covered, or has unusual layout/size. Wait for visibility, scroll it into view, and inspect the resulting viewport and element dimensions.
Access denied, CAPTCHA, or repeated redirects The site is enforcing access controls or has redirected automation. Do not attempt to defeat the control. Review site terms and contact the administrator if the access is legitimate.

8. Performance, reliability, and cost

For Selenium, browser startup and page rendering are usually the main work in a capture run. Reuse one driver for a small batch of permitted pages when appropriate, but always call quit() in a finally block so browser processes are released after success or failure. Keep waits bounded, capture only the needed scope, and avoid unnecessary reloads. A page-specific wait is more reliable than choosing an arbitrary long delay.

WebDriver and the browser run locally or in your own execution environment, so account for that runtime and its maintenance. Selenium itself does not charge per screenshot; any infrastructure, browser hosting, or storage cost depends on your setup. A ScreenshotNeo API request avoids setting up a browser for that capture. ScreenshotNeo bills only clean shots: bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses include X-Page-Verdict and X-Billed headers. Its free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. See ScreenshotNeo for the product and plans.

9. Or skip the browser setup

Use one API request if you want a screenshot without installing and managing a browser. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://example.gov.in/ \
  -o court-page.webp

See the API docs for configuration and response details. Sign up for 1,000 free screenshots a month, with no card required.

10. FAQ

Can I use this screenshot as proof of a court order?

No. Treat it as a visual capture only. Verify legal information against the relevant authority or official record; the eCourts portal says online information is not meant for legal evidence.

Will the same Selenium selector work on every Indian court portal?

No. The portal links to services and external sites with different page structures. Choose and verify a locator on the exact target page.

Does save_screenshot capture the entire page?

It captures the current browsing context/window. Verify any browser-specific full-page approach against the browser and version you use.

Do I need Selenium if I only need an image?

No. A screenshot API such as ScreenshotNeo can capture a URL with an HTTP request when you do not need to operate a browser session or interact with a form first.