How to Capture an Indian Government Website Screenshot When It Blocks Cloud Servers
If a cloud screenshot service is blocked, capture the page in a browser on a network the site allows. Here is a safe Playwright workflow, plus what to record and when to stop.
If a cloud screenshot service cannot open an Indian government website, try the same public URL in a normal browser on a network the site allows. If the page shows a CAPTCHA, denial message, or other access control, stop and ask the department or site administrator for an approved route. A screenshot library captures a page the browser can already access; it does not make an inaccessible page accessible.
This guide shows how to capture an accessible page with Playwright, choose between viewport and full-page output, keep useful capture context, and diagnose common failures without trying to evade a block.
1. Understand what the cloud failure means
A cloud capture service and your own browser may reach a site from different networks and sessions. Government websites can use security controls such as CAPTCHA and web application firewalls, so a cloud request may receive a challenge or denial page instead of the public page. The specific cause depends on the site and the response; without the error text, do not assume that every cloud provider or every visitor is blocked. The Guidelines for Indian Government Websites and apps (GIGW) covers government sites and apps across central, state, district, and local bodies.
First establish what happened. Record the exact URL, the time and time zone of the failed request, the returned status or error text, and—if available—the denial-page capture. That record helps distinguish a network failure, an access-control response, and a page that loaded incompletely.
2. Capture the page in a browser the site permits
- Open the exact public URL in a regular browser on a network you are permitted to use. Follow the site’s displayed instructions and terms.
- Confirm that the intended page—not a challenge, denial, login, or error page—is visible. If an access control appears, stop. Do not repeatedly retry, automate CAPTCHA solving, rotate addresses, impersonate a visitor, or otherwise work around an explicit block.
- Choose the capture area. Use a viewport screenshot for what is visible on screen. Use a full-page screenshot when content below the fold matters.
- Save the screenshot and record the URL, capture time and time zone, browser or tool, viewport dimensions, and whether the image is viewport-only or full-page. Note any visible loading state, cookie banner, or authentication requirement.
For a one-off capture, the browser’s built-in screenshot function may be enough. For repeatable scripted captures on a machine and network that can access the page, Playwright provides viewport, full-page, and element screenshots. Its screenshot documentation describes these capture modes and options.
3. Runnable Playwright example in Node.js
This script opens a URL in Chromium, waits for the document to load, and saves either the visible viewport or the full scrollable page. Use it only where the site permits access. It does not solve or bypass access controls.
npm init -y
npm install playwright
npx playwright install chromium
// capture.mjs
import { chromium } from 'playwright';
const url = process.argv[2];
const mode = process.argv[3] ?? 'viewport';
if (!url || !['viewport', 'full'].includes(mode)) {
console.error('Usage: node capture.mjs <public-url> [viewport|full]');
process.exit(2);
}
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage({
viewport: { width: 1440, height: 1000 },
deviceScaleFactor: 1,
});
const response = await page.goto(url, {
waitUntil: 'domcontentloaded',
timeout: 60000,
});
console.log({
requestedUrl: url,
finalUrl: page.url(),
status: response?.status() ?? null,
viewport: page.viewportSize(),
capturedAt: new Date().toISOString(),
mode,
});
// Inspect the page before saving. If it is a CAPTCHA, denial, login,
// or error page, stop and use an approved access route instead.
await page.screenshot({
path: mode === 'full' ? 'screenshot-full.png' : 'screenshot.png',
fullPage: mode === 'full',
animations: 'disabled',
});
} finally {
await browser.close();
}
Run it with the actual public URL. Quote the URL so shell characters such as ampersands are not interpreted by your shell:
node capture.mjs 'https://example.gov.in/public-page' viewport
node capture.mjs 'https://example.gov.in/public-page' full
The example records the final URL and HTTP status when Playwright receives a response, but those values do not prove that the intended content loaded. Inspect the rendered page and the saved image. A redirect, challenge page, or error document can still produce a valid image file.
4. Choose the right screenshot options
| Need | Use | What to keep in mind |
|---|---|---|
| Visible screen state | Viewport screenshot (the default) | Records only the current viewport; below-the-fold content is omitted. |
| All scrollable content | fullPage: true |
Creates a tall image. Long pages can take longer and produce large files; sticky or dynamic page elements may not look like a single normal viewport. |
| A particular component | page.locator('selector').screenshot({ path: 'element.png' }) |
Use a selector that identifies the intended element. A missing or ambiguous element can fail or capture the wrong region. |
| Repeatable dimensions | Set viewport on the browser context or page |
Record width and height with the output. A different viewport can change responsive layout and visible content. |
| Higher pixel density | Set deviceScaleFactor when creating the page or context |
More pixels increase image size and capture cost in time and storage. |
| Clip to a region | Use the screenshot API’s clip option | Coordinates are relative to the page; clipping is useful for a specific region, not a substitute for documenting the full page. |
| Keep image in memory | Call page.screenshot() without a path |
Playwright returns image bytes that can be passed to another process or saved by your application. |
Playwright’s screenshot API also supports image format, quality, and clipping options. Choose PNG when lossless output matters; JPEG or WebP may be appropriate when smaller image files are more useful. The selected format does not change what the browser was able to access.
5. Make the capture reproducible and useful as a record
A screenshot is a visual record of what one browser rendered at one time, under its current network, viewport, and session conditions. It does not establish that every visitor saw the same page, that uncaptured parts were unchanged, or that a cloud service received the same response.
- Keep the original image file; avoid overwriting it with a resized or annotated copy.
- Store the exact URL, capture timestamp and time zone, browser or tool, viewport dimensions, and capture mode alongside the image.
- Record the visible state, including any loading indicator, consent banner, login state, or error message.
- If the cloud request failed, preserve its error text or response separately. The local browser capture documents what that browser saw, not what the cloud server saw.
- If the image is for a formal record, follow your organization’s retention and evidence-handling process. A screenshot alone does not prove when or how a page was served.
6. Troubleshoot common failures
| Symptom | Likely cause | What to do |
|---|---|---|
| Cloud tool shows a CAPTCHA or denial page | The cloud request received an access-control response. | Preserve its response details. Try the public URL in a browser on a network the site permits. If access is denied there too, contact the site owner for an approved route. |
| Playwright saves a screenshot of the wrong page | The navigation redirected or rendered a challenge, login, or error page. | Check page.url(), the response status, and the image itself. Do not treat a successfully written file as proof that the target content was reached. |
net::ERR_... or navigation timeout |
The browser could not complete navigation in the available time; the cause may be connectivity, DNS, TLS, server delay, or an access restriction. | Check the URL and permitted network access. Compare with a normal browser on that same machine. Preserve the precise error; do not repeatedly retry a clear denial. |
| Blank or partly rendered screenshot | The page may still be loading content, depend on scripts, or have failed subresources. | Inspect the page in a visible browser and wait for the relevant content to appear before capturing. If it remains blank, document that state rather than claiming the page loaded. |
| Full-page image omits expected material | Content may load only after scrolling, or the site may use dynamic or nested scrolling areas. | Inspect the page and determine whether the missing material is actually present. Capture the needed visible region or use an approved page export if the full content must be preserved. |
| Element screenshot reports no element | The selector does not match an element in the rendered page, or the expected page never loaded. | Confirm the correct page and selector in the browser. If the page is blocked, stop rather than trying to defeat its controls. |
| Screenshot differs between runs | Viewport, session, page content, or loading state differed. | Keep viewport and capture procedure consistent; record the time and session conditions. Dynamic pages can change even when the URL is the same. |
7. Performance, reliability, and cost
For a local Playwright capture, the work includes starting a browser, loading the page and its resources, rendering, and encoding the image. Full-page captures and higher pixel density can increase time and file size. Use a viewport capture when only the visible state matters; use full-page capture when the additional content is relevant.
Reliability depends on the site being reachable from the chosen network and on the page finishing enough rendering to show the intended state. A longer timeout can accommodate a slow navigation, but it cannot grant access or resolve a denial. Record failures instead of silently treating them as successful captures. Local browser automation has no per-shot ScreenshotNeo charge, though it uses your machine and requires you to maintain the runtime and browser installation.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. If the target is accessible to the service, one GET request can return an image or PDF. It accepts cookie banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. An MCP server lets AI agents such as 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 screenshots. Every feature is on every plan.
Important: ScreenshotNeo is still a cloud service. If a government site blocks its cloud request, use the permitted browser workflow above or ask the site owner for an approved access route; ScreenshotNeo does not make a blocked page accessible.
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.gov.in/public-page -o shot.webp
Python:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={
"access_key": "YOUR_API_KEY",
"url": "https://example.gov.in/public-page",
},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://example.gov.in/public-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('shot.webp', Buffer.from(await res.arrayBuffer()))
);
See the ScreenshotNeo API documentation for request options. Create a free account for 1,000 screenshots a month with no card.
Frequently asked questions
Can I capture a government site if it asks me to sign in?
Only use an account and access route you are authorized to use. Do not try to bypass the sign-in or any other access control.
Does a successful screenshot prove the site was publicly available?
No. It shows what the selected browser rendered under its particular network, session, viewport, and capture time.
Should I use a full-page screenshot for every record?
No. Use it when below-the-fold material matters. A viewport image is clearer when the question concerns only the visible screen.
What if I need an official or stable copy?
Ask the department or site administrator whether it can provide an official copy, export, allowlist, or other approved route.
Sources
- Playwright: Screenshots — viewport, full-page, buffer, and element capture examples.
- Guidelines for Indian Government Websites and apps (GIGW) — official government website and app guidance.


