ScreenshotNeo

BlogHow-to

How to Capture Website Screenshots from an Indian IP Address with Playwright

Use an India-based proxy with Playwright to capture a website as visitors in India see it. Learn how proxy routing differs from geolocation and how to troubleshoot regional results.

By the ScreenshotNeo team4 October 20269 min read

To capture a site from an Indian IP address, route Playwright’s browser traffic through an HTTP or SOCKS proxy whose public egress is in India, then take a screenshot. Playwright configures the proxy; your proxy provider supplies the Indian IP. Browser geolocation is a separate signal and does not change the network’s IP address.

Playwright’s proxy configuration supports a server address, optional credentials, and bypass rules. Confirm the provider’s endpoint and current Indian egress, and verify the result before relying on a capture. A site may also use locale, cookies, account settings, or its own server rules to decide what content to show.

1. Set up Playwright and an India-egress proxy

  1. Install Playwright for your preferred language and install its browser binaries. See the browser installation guide.
  2. Obtain an authorized proxy endpoint that explicitly offers Indian egress. Check the protocol, host, port, authentication, whether the address rotates, and whether your intended testing is allowed.
  3. Keep proxy credentials in environment variables or a secrets manager. Do not commit them to source control or print them in logs.
  4. Configure the proxy at browser launch or browser-context scope, navigate to the target, and capture the page.

Compare proxy services by their verified Indian location, fixed or rotating sessions, HTTP or SOCKS support, authentication, session stability, permitted uses, target-site compatibility, and total cost. Playwright documents how to connect to a proxy; it does not certify proxy providers or their locations.

2. Capture a page with Playwright in Node.js

This runnable CommonJS example expects INDIA_PROXY_SERVER and, if required by your provider, INDIA_PROXY_USERNAME and INDIA_PROXY_PASSWORD in the environment. It saves a full-page PNG. Replace the example URL with the site you are authorized to inspect.

const { chromium } = require('playwright');

async function main() {
  const proxy = { server: process.env.INDIA_PROXY_SERVER };
  if (!proxy.server) throw new Error('Set INDIA_PROXY_SERVER');
  if (process.env.INDIA_PROXY_USERNAME) proxy.username = process.env.INDIA_PROXY_USERNAME;
  if (process.env.INDIA_PROXY_PASSWORD) proxy.password = process.env.INDIA_PROXY_PASSWORD;

  const browser = await chromium.launch({ proxy });
  try {
    const context = await browser.newContext({
      viewport: { width: 1440, height: 1000 },
      locale: 'en-IN',
    });
    const page = await context.newPage();
    await page.goto('https://example.com', {
      waitUntil: 'domcontentloaded',
      timeout: 60000,
    });
    // Replace or supplement this with an application-specific readiness check.
    await page.screenshot({ path: 'india-view.png', fullPage: true });
    await context.close();
  } finally {
    await browser.close();
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Install the package with npm install playwright and install the Chromium binary with npx playwright install chromium. If your project uses ECMAScript modules, import chromium from playwright and use the same async workflow. Choose a readiness condition that fits the site: domcontentloaded avoids waiting for every resource, while an explicit locator wait can confirm that a key element has appeared. networkidle is not a universal signal of readiness; analytics, polling, and other persistent activity can keep a page busy.

Current viewport or full page

Omit fullPage (or set it to false) to capture the current viewport. Set it to true to capture the full page. Choose the viewport deliberately: it affects responsive breakpoints and therefore the layout in the screenshot. See the official screenshot guide.

3. Python version

Install the Python binding and browser binaries with pip install playwright and playwright install chromium. This script uses the same proxy environment variables and saves a full-page screenshot.

import os
from playwright.sync_api import sync_playwright

server = os.environ.get("INDIA_PROXY_SERVER")
if not server:
    raise RuntimeError("Set INDIA_PROXY_SERVER")

proxy = {"server": server}
if os.environ.get("INDIA_PROXY_USERNAME"):
    proxy["username"] = os.environ["INDIA_PROXY_USERNAME"]
if os.environ.get("INDIA_PROXY_PASSWORD"):
    proxy["password"] = os.environ["INDIA_PROXY_PASSWORD"]

with sync_playwright() as p:
    browser = p.chromium.launch(proxy=proxy)
    try:
        context = browser.new_context(
            viewport={"width": 1440, "height": 1000},
            locale="en-IN",
        )
        page = context.new_page()
        page.goto(
            "https://example.com",
            wait_until="domcontentloaded",
            timeout=60000,
        )
        # Add a site-specific readiness check if needed.
        page.screenshot(path="india-view.png", full_page=True)
        context.close()
    finally:
        browser.close()

The Python API follows the same browser, context, page, navigation, and screenshot sequence. Check the documentation for the Playwright version installed in your project if adapting options between language bindings.

4. Configure proxy, locale, and geolocation correctly

Proxy scope and options

You can set proxy when launching the browser or when creating a browser context. The relevant fields are:

Field Purpose Notes
server Proxy endpoint, including its scheme and port Use the scheme and address supplied by the provider, such as an HTTP or SOCKS endpoint. Confirm protocol support with the provider.
username, password Proxy authentication, if required Supply credentials separately; avoid putting secrets in a URL that may appear in logs.
bypass Domains that should connect without the proxy Do not bypass the target or its relevant hosts if you need their requests to leave through India.

A browser-level setting applies to its contexts; context-level configuration lets you choose a proxy for a particular context. Proxy formats and support can vary by provider, so use the endpoint exactly as documented for your account. See Playwright’s BrowserType API.

Geolocation and locale are separate signals

Use an Indian-egress proxy for IP-based regional behavior. Set browser geolocation only when the site requests device location, and grant the browser permission as well. For example, a context can be created with coordinates and permission like this:

const context = await browser.newContext({
  locale: 'en-IN',
  geolocation: { latitude: 19.0760, longitude: 72.8777 },
  permissions: ['geolocation'],
});

These coordinates represent an example location in Mumbai; choose coordinates appropriate to the location you intend to emulate. This setting affects browser-reported location when requested. It does not route traffic through India or change the public IP. locale can affect language and formatting but does not guarantee region-specific content either. Playwright describes these as browser context emulation settings in its emulation guide and network guide.

Verify the network egress

Before capturing important pages, confirm the public egress IP and country using your provider’s diagnostics or an IP-check endpoint you are permitted to access. Check from the same browser context or through provider diagnostics that reflect the same proxy route. Treat this as a separate check from setting geolocation. The endpoint’s country, availability, and the target site’s acceptance must be verified with the provider and site; Playwright cannot verify them for you.

5. Wait for the right page state

A screenshot is only as complete as the page state captured. Choose an intentional viewport and wait for meaningful content rather than assuming that one generic navigation event covers every site.

  • Use a locator wait for a specific heading, product card, or other element that indicates the page is ready.
  • For lazy-loaded content, scroll through the page or trigger the site’s own loading behavior before taking a full-page capture.
  • If fonts or images arrive after the main content, wait for the relevant assets or application state before capture.
  • For a single component, capture a locator rather than the whole page. For long pages, remember that full-page capture can create a large image and may interact differently with sticky elements.

See the screenshot guide for screenshot modes and options. There is no single wait condition that guarantees every site’s client-side rendering is complete.

6. Troubleshooting

Symptom Likely cause Fix
The page shows a non-Indian version The endpoint does not currently egress in India, the target uses other region signals, or a session cookie/account setting overrides the IP. Verify egress from the same route, check provider location and session behavior, and inspect cookies, locale, and account region.
Proxy connection fails Wrong scheme, host, port, unsupported protocol, invalid credentials, or provider allowlist requirements. Copy the endpoint details from the provider, confirm HTTP/SOCKS support and authentication format, and check any IP allowlist.
The target bypasses the proxy A bypass rule excludes the target or its required hostnames. Review the proxy’s bypass setting and route every relevant target host through the proxy.
Navigation times out The proxy is slow or unavailable, the target is slow, or a wait condition such as network idle never occurs. Check proxy health, use a realistic timeout, wait for a meaningful locator, and avoid waiting for network idle on pages with ongoing requests.
Screenshot is blank or incomplete The wrong URL loaded, app rendering had not finished, lazy content was not triggered, or the viewport did not match the intended device. Inspect the final URL and page state, wait for a site-specific readiness signal, scroll to trigger lazy content, and set viewport dimensions intentionally.
Geolocation-dependent content is still wrong Coordinates were set without permission, or the site actually keys on IP or another signal. Grant geolocation permission and set coordinates if the browser API is used; retain the Indian proxy for IP-based behavior.
Browser installation is blocked An installation proxy is confused with runtime page proxy configuration. Playwright’s HTTPS_PROXY installation guidance concerns downloading browser binaries. Configure website traffic with the browser or context proxy option. See browser installation.

7. Performance, reliability, and cost

Every navigation and page resource travels through the proxy, so latency and availability depend on the proxy route as well as the target. Full-page screenshots and high device scale factors use more memory and produce larger files than viewport captures. Capture only the page area you need, choose a suitable viewport, and avoid unnecessary repeated navigations.

For repeatable regional checks, record the proxy region and session mode with each run, verify egress, and capture the final URL and relevant page state alongside the image. Rotating endpoints can change the egress IP between requests; a stable session may be preferable when a flow depends on cookies or multiple page loads. Ask the provider about session controls and pricing: this research does not validate any particular vendor, rate, or reliability figure. Also account for the target site’s rules and the proxy provider’s permitted-use terms.

Or skip the browser setup

If you need the screenshot artifact without managing a Playwright browser and proxy, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. Its API can capture a URL, but it does not let you choose an Indian network egress, so use Playwright with a verified India proxy when the Indian IP itself is required.

ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

For a quick capture, create an API key and use the ScreenshotNeo API documentation:

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

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Sign up for the free plan.

Frequently asked questions

Does Playwright provide an Indian IP address?

No. Playwright configures a proxy connection; the proxy provider controls the network egress and its location.

Will an Indian IP guarantee that I see the India version?

No. A site may also use cookies, account settings, browser locale, geolocation, or server-side rules.

Does setting locale: 'en-IN' make requests come from India?

No. Locale affects browser language and formatting signals. Use a verified Indian-egress proxy for the network route.

Can I use a proxy only for one test?

Yes. Configure it on a browser context when you need per-context proxy settings, or launch a separate browser with the desired proxy.