Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › government websites

How to Take Selenium Screenshots of Hindi Government Websites with Headless Chrome

By Freedom251 Team · · 5 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium to launch Chrome in headless mode, set a deliberate viewport, wait for the page and its fonts, then save the browser’s current window as a PNG. For Hindi pages, verify the image itself: a successful file write does not guarantee Devanagari rendered correctly. The example below is a starting point for a page you are authorized to access; replace the sample government URL with your target.

Capture a Hindi website with Selenium and headless Chrome

This Python workflow waits for the document to finish loading and for available web fonts to settle before taking a viewport screenshot. It also checks Selenium’s return value and always closes the browser session.

As an Amazon Associate I earn from qualifying purchases.

from pathlib import Path

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

url = "https://example.gov.in/"  # Replace with the page you are authorized to capture.
output = Path("screenshot.png").resolve()

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--window-size=1365,1200")

driver = webdriver.Chrome(options=options)
try:
    driver.get(url)
    WebDriverWait(driver, 30).until(
        lambda d: d.execute_script("return document.readyState") == "complete"
    )
    driver.execute_async_script("""
        const done = arguments[0];
        if (document.fonts && document.fonts.ready) {
          document.fonts.ready.then(() => done());
        } else {
          done();
        }
    """)

    if not driver.save_screenshot(str(output)):
        raise RuntimeError(f"Could not save screenshot to {output}")
    print(f"Saved {output}")
finally:
    driver.quit()

Install Selenium in the Python environment running the script with python -m pip install selenium. Selenium’s Chrome guide describes Chrome options and notes that Chrome and ChromeDriver major versions must match. Selenium 4 is compatible with Chrome 75 and later, according to that guide; compatibility still depends on using a matching driver and a functioning browser installation. See Selenium’s Chrome-specific documentation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The code uses --headless, a deliberate viewport size, driver.get(), explicit waits, and save_screenshot(). Selenium documents that save_screenshot() saves the current window to PNG and returns false if saving fails. It does not, by itself, promise a full-document capture. See the Python WebDriver API.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Make sure Devanagari renders correctly

A PNG can be written successfully while Hindi text is still missing or malformed. The browser must have access to a font with Devanagari glyph coverage, either installed in the operating system or loaded by the page. Minimal Linux containers and CI images are common places to check font availability. There is no single font package established here as a universal fix for every Hindi website.

  • Open the saved PNG and check for missing-glyph squares, disconnected vowel marks, unexpected fallback fonts, clipped text, and layout shifts.
  • Wait for the page’s web fonts to load. document.fonts.ready is a useful starting point, but it cannot ensure that every dynamically loaded component has finished rendering.
  • If content appears late, wait for a page-specific landmark or condition instead of relying only on document.readyState.
  • When diagnosing a discrepancy, compare the result with headful Chrome on a known-good environment, and record the environment and viewport used.

Current Chrome Headless uses the same browser implementation as headful Chrome. Google describes the updated Headless mode as arriving in Chrome 112; since Chrome 132, the old Headless implementation is available only as the separate chrome-headless-shell binary. See Chrome Headless mode and the Headless Chrome shell documentation.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Choose the right screenshot size and capture scope

The Selenium call above captures the current browser window, not automatically the entire page. The --window-size=1365,1200 argument sets a repeatable viewport; it does not guarantee that a long page will be captured from top to bottom. Check the output dimensions and visible content to confirm what was captured.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If you need a full-page image, use a tested browser-specific full-page technique or capture sections and stitch them, then inspect the final image. Do not assume that increasing the window height alone will capture every full-page layout correctly. Chrome’s Headless shell documentation discusses the extra work involved in full-page screenshots.

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Keep the browser environment reproducible

For a repeatable job, record the Chrome and ChromeDriver versions, operating-system or container image, available fonts, viewport, device scale factor if you control it, and target URL. Match the Chrome and ChromeDriver major versions as Selenium’s Chrome documentation advises. Verify the exact container image can launch Chrome and has suitable fonts; universal container flags or font-package names are not established by the cited documentation.

Government sites may have their own terms and service constraints. Check the specific site’s rules before repeated or authenticated capture. The Government of India’s GIGW portal provides government website and app guidance, including manuals, accessibility resources, and validation tools; that guidance does not determine whether a particular site permits automation.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Chrome’s command line for a one-off capture

For a static page that needs no interaction or Selenium-specific waits, Chrome’s direct command-line screenshot option is simpler. Chrome documents that --screenshot saves a file named screenshot.png in the current working directory, and its CLI reference includes --window-size and --timeout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chrome --headless --window-size=1365,1200 --timeout=5000 --screenshot https://example.gov.in/

Replace the URL and confirm the installed Chrome binary’s command name for your system. Use Selenium instead when you need to interact with the page, wait for a site-specific condition, or integrate capture into a browser test suite. See Chrome’s Headless command-line reference.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Troubleshoot common failures

  • Chrome fails to start: Confirm Chrome is installed and runnable in the same environment as Selenium, then check that Chrome and ChromeDriver have matching major versions.
  • The screenshot file is absent or saving returns false: Check that the output directory exists and is writable, and use an absolute path as in the example.
  • Hindi appears as squares or broken marks: Check Devanagari font availability in the environment, wait for web fonts, and inspect the actual PNG rather than treating file creation as proof of correct rendering.
  • The page is only partly loaded: Wait for a page-specific element or condition. Document readiness and font readiness do not necessarily cover delayed widgets or content loaded by later scripts.
  • The bottom of the page is missing: The standard Selenium screenshot call captures the current window. Use a full-page capture technique designed for your browser or capture and stitch sections; verify the result.
  • The output differs across machines: Compare Chrome version, driver version, fonts, operating-system image, viewport, and device scale factor. Change one variable at a time to identify the cause.

Or skip the browser setup

ScreenshotNeo provides a one-request screenshot API. It accepts an access key and URL and can return an image or PDF. For example, this cURL request saves a WebP capture of the target page:

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

See the ScreenshotNeo documentation for request options. ScreenshotNeo says it removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also offers an MCP server so AI agents can take screenshots. The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots. Learn more at ScreenshotNeo.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Does a saved PNG prove Hindi rendered correctly?

No. Inspect the image for missing or malformed Devanagari glyphs and layout problems.

Does Selenium’s ordinary screenshot method capture the full page?

No. It captures the current browser window; full-page capture requires a separate technique.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

government websitesHeadless ChromeHindiPythonscreenshotsSelenium

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.