ScreenshotNeo

BlogHow-to

Screenshot Indian Government Scheme Pages in Bengali with Python Selenium

Capture an Indian government scheme page with Selenium, check that Bengali text rendered correctly, and choose between a viewport, element, or full-page screenshot.

By the ScreenshotNeo team4 October 202610 min read

To screenshot an Indian government scheme page in Bengali with Python Selenium, open the target URL in a browser, wait for the content and any web fonts you need, verify Bengali glyphs and layout in that browser environment, then save a PNG. Selenium’s ordinary WebDriver screenshot methods capture the current browser window. For one page element, use its screenshot method; for the entire document, choose a browser API that documents full-page capture, such as Firefox’s Python API.

No target scheme URL is assumed here. Replace the placeholder below with the page you are allowed to access, and check that page’s behavior and rules before automating it. A successful file save alone does not prove that the page loaded fully or that Bengali text rendered correctly.

1. Choose the screenshot scope

Decide what the image must contain before writing the capture code. A browser-window screenshot and a full-document screenshot are different capture modes.

Need Use What to check
What is visible in the browser window driver.save_screenshot(...) or driver.get_screenshot_as_file(...) Set the viewport size before capture; content below the fold is not included.
A specific page component element.screenshot(...) Wait for the element to exist and be visible. The element must fit the browser’s capture behavior.
The entire document, including content below the fold A browser-specific full-page API Use an API documented for the browser in use. Selenium’s Firefox Python API documents full-document screenshot methods; do not assume the same method exists for every browser.

Selenium’s Python API describes save_screenshot(filename) as saving a screenshot of the current window to a PNG file. File-saving methods return a boolean indicating success; check it and handle a failed save.

2. Prepare Selenium and the browser

Install Selenium and set up a supported browser and driver by following the current Selenium documentation for your environment. Browser and driver setup varies by operating system and browser version, so do not assume a driver installed for one machine will work on another. Selenium’s current setup may manage drivers for you, but confirm the documented setup for your chosen browser.

Install the Python package in your project environment:

python -m pip install selenium

Make sure the host environment has a Bengali-capable font available. Noto Sans Bengali UI is one option for Bengali-script UI text. A font being installed does not guarantee that the target page will use it: the page’s CSS, loaded web fonts, and browser font fallback determine what appears. See Noto Sans Bengali and the Google Fonts usage guidance for font and fallback context.

3. Capture the current browser window with Python

This runnable example opens a placeholder URL, waits for the document to reach a useful readiness state, waits for the browser’s font set to report ready, and writes a viewport PNG. Replace the URL and, where possible, the generic readiness condition with one tied to the page content you need. A page’s load event does not necessarily mean that every asynchronous component has settled.

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

url = "https://example.gov.in/replace-with-scheme-page"
output = Path("scheme-bengali.png")

options = webdriver.ChromeOptions()
# Uncomment for a headless run when a graphical browser is not available.
# options.add_argument("--headless=new")
options.add_argument("--window-size=1440,1200")

driver = webdriver.Chrome(options=options)
try:
    driver.get(url)

    wait = WebDriverWait(driver, 30)
    wait.until(lambda d: d.execute_script("return document.readyState") == "complete")
    # This waits for fonts known to the page. It does not prove that a specific
    # remote font was selected or that all page-specific content has loaded.
    wait.until(lambda d: d.execute_script(
        "return !document.fonts || document.fonts.status === 'loaded'"
    ))

    # Add a page-specific wait when the content is asynchronous, for example:
    # wait.until(lambda d: d.find_element("css selector", "main.scheme-details").is_displayed())

    output.parent.mkdir(parents=True, exist_ok=True)
    saved = driver.save_screenshot(str(output))
    if not saved:
        raise OSError(f"Selenium could not save screenshot to {output}")
    print(f"Saved viewport screenshot: {output.resolve()}")
finally:
    driver.quit()

The code waits for document readiness and the browser font set, but neither condition is a universal signal that a specific scheme page is visually complete. Add a wait for a meaningful element or state on the page, then inspect the resulting image. If the page uses a remote web font, blank space or fallback text may appear before that font loads; Google Developers documents this web-font loading behavior in its technical considerations.

4. Verify Bengali text before relying on the image

Check the PNG itself at its intended display size. Look for missing-glyph boxes, broken conjuncts, clipped vowel signs, unexpected line breaks, overlapping text, and fallback fonts that make labels hard to read. Confirm the important Bengali text appears in the captured region, not just elsewhere on the page.

  • Confirm the host has a Bengali-capable font and restart the browser session after changing system fonts if needed.
  • Inspect the page’s computed font stack if the font looks wrong. A CSS font-family stack controls fallback, and page styles may override a preferred font.
  • Wait for the page’s own web-font and content readiness. document.fonts.status is a broad signal; if the target has a known font, a page-specific check may be needed.
  • Compare the browser rendering with the saved PNG. If both show the same missing glyphs or layout issue, the problem is likely rendering or page styling rather than saving.

Noto’s Bengali UI font documentation describes support for the Bengali script, while its font guidance explains browser fallback via CSS font-family stacks: Noto Sans Bengali and using Google Fonts. Font availability and whether a target page uses a particular font depend on the environment and the page.

5. Capture a single element

When the image only needs a scheme summary, application panel, or another component, wait for that element and use its screenshot method. Element screenshot support is documented in Selenium’s window and element interactions documentation.

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/replace-with-scheme-page"
output = Path("scheme-details.png")

driver = webdriver.Chrome()
try:
    driver.get(url)
    wait = WebDriverWait(driver, 30)
    details = wait.until(EC.visibility_of_element_located(
        (By.CSS_SELECTOR, "main")
    ))
    if not details.screenshot(str(output)):
        raise OSError(f"Could not save element screenshot to {output}")
finally:
    driver.quit()

Replace main with a selector that uniquely identifies the desired element on the real page. If the selector matches a large container, the output may be correspondingly large; if it matches a hidden or zero-size element, the capture may fail or be unusable.

6. Capture a full document with Firefox

For a full-document image, use a browser and method whose Selenium API explicitly provides that mode. Selenium’s Firefox Python API documents get_full_page_screenshot_as_file and save_full_page_screenshot. This example uses the former:

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

url = "https://example.gov.in/replace-with-scheme-page"
output = Path("scheme-full-page.png")

driver = webdriver.Firefox()
try:
    driver.get(url)
    wait = WebDriverWait(driver, 30)
    wait.until(lambda d: d.execute_script("return document.readyState") == "complete")
    wait.until(lambda d: d.execute_script(
        "return !document.fonts || document.fonts.status === 'loaded'"
    ))
    if not driver.get_full_page_screenshot_as_file(str(output)):
        raise OSError(f"Could not save full-page screenshot to {output}")
finally:
    driver.quit()

See the Selenium Firefox WebDriver API for the documented full-page methods and current browser-specific details. Full-page behavior can still vary with browser versions and page structure. Long pages, sticky elements, lazy-loaded images, and content that appears only after scrolling need special attention. If the page loads content as it enters the viewport, scroll through it and wait for that content before taking the screenshot; then inspect for gaps or repeated sticky headers.

7. Use cURL, Python, or Node.js with ScreenshotNeo

If you need a screenshot without managing a browser and driver, ScreenshotNeo is a website screenshot API and MCP server. Its one-request API accepts a URL and returns a screenshot or PDF. Here is the requested one-call example, adapted to a placeholder scheme page. See the ScreenshotNeo API documentation for parameters and response details.

cURL

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

Python

import requests

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

Node.js

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

Keep the API key in a secret store or environment variable in production rather than committing it to source control. Check the returned content type and response headers when integrating the API, and follow the docs for supported output and options.

8. Troubleshooting

Symptom Likely cause What to do
WebDriver cannot start Browser missing, incompatible browser/driver setup, or environment configuration issue. Follow Selenium’s current setup instructions for the chosen browser and verify the browser is installed and launchable in the same environment.
PNG is missing or the save method returns false Output directory is absent, path is unwritable, or the file operation failed. Create the parent directory, use an absolute path, check permissions, and handle the method’s boolean result.
Image contains only part of the page The standard WebDriver call captures the current window viewport. Use the browser’s documented full-page API, such as Firefox’s Python full-page method, or capture a specific element.
Bengali characters appear as boxes or are missing No suitable font is available, the chosen font lacks the glyphs, or fallback/rendering did not work. Install or provide a Bengali-capable font in the capture environment, inspect the computed font stack, and verify the browser rendering and saved image.
Bengali text is blank or uses an unexpected fallback A web font may still be loading when the screenshot is taken. Wait for font readiness and a page-specific readiness condition, then inspect the output. A generic navigation completion check may not cover asynchronous fonts.
Important content is absent or a section is empty The page loads content asynchronously, requires scrolling, or the wait condition was too broad. Wait for the relevant element or state. For lazy-loaded sections, scroll them into view and wait before capturing.
Element screenshot fails or is cropped unexpectedly The selector targets a hidden, zero-size, or unsuitable element. Use a selector for the visible container, wait for visibility, and inspect its size and the resulting capture.
Capture hangs or the page never becomes ready The target may keep network activity open or depend on a resource that does not settle. Use a bounded explicit wait for the content you need, handle timeout errors, and check the target page’s behavior and access rules. Do not wait indefinitely for every network request to stop.

9. Performance, reliability, and cost

A local Selenium workflow starts and controls a browser for each session, so startup time, memory use, browser availability, and cleanup matter. Reuse a session when taking several related captures, set bounded waits, use an appropriate viewport, and always call quit() in a finally block. Full-document captures can produce much larger files and take longer than viewport or element captures. Lazy content may require deliberate scrolling and additional waits.

Selenium itself is browser automation software; the browser, host, and any infrastructure you run it on determine your operating costs. This research does not establish a benchmark or a target site’s performance. For ScreenshotNeo, the supplied plans are Free with 1,000 shots per month and no card; Starter $5 for 3,000; Growth $15 for 15,000; Pro $39 for 60,000; Scale $99 for 250,000; and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan. ScreenshotNeo says bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with page verdict and billing headers in each response. Check the docs and plan page for current implementation details.

10. Or skip the browser setup

Send one request to ScreenshotNeo’s API and save the returned image. Cookie banners, popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents, including Claude and Cursor, take screenshots. The free plan includes 1,000 screenshots a month 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/replace-with-scheme-page -o scheme.webp

See the API documentation and ScreenshotNeo for the service details. Sign up for 1,000 free screenshots a month, with no card.

Frequently asked questions

Does Selenium automatically make a screenshot full-page?

No. The usual WebDriver screenshot method captures the current window. Use an explicitly documented full-page method for the browser you selected.

Can I force the target page to use Noto Sans Bengali?

Installing a font makes it available to the browser, but the page’s CSS and font fallback determine what is used. Check the rendered page and its computed font styles; do not assume the target accepts an override.

Does this tutorial verify a specific government portal?

No. It uses a placeholder URL because no particular scheme page was researched. Check the target page’s access rules and behavior before automating it.

What should I archive with the PNG?

For reproducibility, keep the target URL, capture date, browser and Selenium versions, viewport dimensions, and whether the image is viewport, element, or full-page. These details help explain later rendering differences.