How to Capture Indian Flight Booking Pages with an AI Agent
Use an AI agent and Playwright to capture a flight booking page as a viewport, element, or full-page screenshot, with settings for clarity and privacy.
An AI agent can capture an Indian flight booking page by using Playwright to navigate an authorized browser session to the state it needs, then save a viewport, element, or full-page screenshot. Use an accessibility snapshot when the agent also needs structured content or interaction targets: an image shows appearance, not page structure.
This guide demonstrates the capture mechanics. It does not establish whether any particular airline or booking website permits automated access. Check the target site’s current terms and access controls before using an agent on a live page.
1. Choose what the agent needs to capture
Capture scope depends on the task:
- Viewport: the currently visible browser area. Useful for documenting the page as a user sees it at a particular scroll position.
- Element: one result card, fare panel, or other specific element. Useful for a focused comparison.
- Full page: the full scrollable document, including content below the fold. This can produce a tall image and may be less convenient to review.
- Clip: a defined rectangular region when the desired area does not correspond to one element.
A screenshot is visual evidence of what appeared in the browser at capture time. It does not establish that a fare or itinerary is bookable, final, or still available.
2. Capture with Playwright in Python
Install Playwright and its Chromium browser, then save this as capture_flight_page.py. Replace the example URL with a page you are authorized to access. The script captures the current viewport by default; the comments show how to select full-page or element capture instead.
from pathlib import Path
from playwright.sync_api import sync_playwright
TARGET_URL = "https://example.com/flight-search"
OUTPUT = Path("flight-booking-page.png")
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page(viewport={"width": 1440, "height": 1000})
page.goto(TARGET_URL, wait_until="domcontentloaded", timeout=60_000)
# Navigate to the intended state using authorized browser controls.
# Example: page.get_by_role("button", name="Search flights").click()
page.wait_for_load_state("networkidle", timeout=15_000)
# Viewport capture (default):
page.screenshot(path=str(OUTPUT), type="png")
# For a full-page capture, use this instead:
# page.screenshot(path="flight-booking-full.png", full_page=True, type="png")
# For a focused element, use a locator:
# page.locator("[data-testid='flight-result']").first.screenshot(
# path="flight-result.png", type="png"
# )
browser.close()
Install the package and browser with:
python -m pip install playwright
python -m playwright install chromium
python capture_flight_page.py
The example uses domcontentloaded so navigation can proceed even when a page continues background requests. Waiting for networkidle is optional and can time out on pages that keep requests open; if so, wait for a specific result element or use a short deliberate delay after the page reaches the desired state.
3. Capture with Playwright in Node.js
This runnable example uses the Playwright package. Save it as capture-flight-page.mjs, set TARGET_URL to an authorized page, and run it after installing Chromium.
import { chromium } from "playwright";
const targetUrl = "https://example.com/flight-search";
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
try {
await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: 60_000 });
// Use authorized browser controls to reach the intended page state.
await page.waitForLoadState("networkidle", { timeout: 15_000 }).catch(() => {});
// Viewport capture:
await page.screenshot({ path: "flight-booking-page.png", type: "png" });
// Full-page capture:
// await page.screenshot({ path: "flight-booking-full.png", fullPage: true });
// Element capture:
// await page.locator("[data-testid='flight-result']").first().screenshot({
// path: "flight-result.png",
// });
} finally {
await browser.close();
}
npm install playwright
npx playwright install chromium
node capture-flight-page.mjs
4. Use an AI agent to decide when to capture
Browser automation and screenshot capture are separate steps: the agent first navigates and interacts with the page, then captures after the relevant state is visible. Use the agent’s normal browser controls to reach the search results, open a detail panel, or move to the relevant scroll position. Do not assume a click succeeded just because the agent issued it; inspect the resulting state before saving the image.
When the agent needs to identify page structure or interaction targets, use an accessibility snapshot as a companion to the screenshot. The snapshot helps explain what elements are present; the screenshot records their visual presentation. See the official Playwright accessibility snapshot guidance and screenshot guide.
5. Select format, scale, clipping, and masking
| Setting | When to use it | Practical note |
|---|---|---|
| Type | PNG for crisp text and interface details; JPEG when a smaller photographic image is suitable. | Playwright supports screenshot output configuration including file type. Choose based on readability and downstream use. |
| Scale | CSS scale for one output pixel per CSS pixel; device scale for more output pixels. | Higher pixel count can improve detail but increases image dimensions and file size. |
| Full page | When content below the fold matters. | Long booking results can create a very tall image; capture a particular element if only one result is needed. |
| Element | When the comparison concerns a result card or panel. | Use a stable locator and ensure the element is visible before capture. |
| Clip | When a rectangular region is the desired evidence. | Use coordinates relative to the page and verify the rectangle still covers the intended content at the chosen viewport. |
| Mask | When matching sensitive regions should be covered in the saved image. | Decide which regions to mask before saving or sharing the capture. |
For reproducible records, use a descriptive filename and store the page or route, capture time, viewport, and relevant agent state alongside the image. Review the output to confirm the intended content is visible.
6. Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One request can return an image or PDF, while its MCP tools let AI agents use take_screenshot, get_page_info, and capture_pdf. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/flight-search -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com/flight-search"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com/flight-search' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Cookie banners are accepted like a visitor would accept them, and 60+ known consent platforms, newsletter popups, and chat widgets are removed before the shot; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. The MCP server lets AI agents take screenshots. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card.
7. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Navigation times out | The page is slow, or a background request keeps running. | Use domcontentloaded for navigation, then wait for a specific visible result or a bounded delay. Increase the timeout only when the page genuinely needs more time. |
| Capture is blank or incomplete | The screenshot was taken before the intended page state appeared, or content loads after scrolling. | Wait for a visible target, inspect the page, and capture after it reaches the required state. For below-the-fold content, use full-page capture. |
| Element locator fails | The selector does not match the current page or the element is not rendered yet. | Inspect the DOM or accessibility snapshot, choose a locator tied to the intended element, and wait for it to become visible. |
| Full-page image is too large | The document is long and the capture includes all of it. | Capture the relevant element or use a clip. Split the workflow into focused captures if several distant areas matter. |
| Text looks too small | The image is being viewed scaled down, or the capture uses CSS-pixel dimensions for a high-density display. | Capture the relevant element at device scale or use a closer crop; check image dimensions before sharing. |
| Screenshot contains private information | Personal, account, or booking details were visible at capture time. | Review the page state before capture, mask matching sensitive regions, and avoid sharing the image until reviewed. |
8. Performance, reliability, and cost
Capture time depends on page navigation, scripts, images, and the readiness condition you choose; the source material provides no benchmark for flight booking pages. Avoid an unbounded wait for network idleness on pages with persistent requests. Waiting for the specific content you need is often more predictable. Full-page and device-scale captures create larger images, which take more storage and transfer than a viewport capture.
For repeatable evidence, capture the same route and state, keep the viewport and scale consistent, record capture time, and inspect the output. Treat a screenshot as a record of one moment, not a validation of current inventory, final fare, or booking success. Confirm site-specific automation permissions before running an agent against a live booking page.
With Playwright, the direct cost considerations are your own browser execution and storage environment; this guide does not provide a price estimate. For ScreenshotNeo usage and plan details, the published options are Free with 1,000 shots monthly, Starter at $5 for 3,000, Growth at $15 for 15,000, Pro at $39 for 60,000, Scale at $99 for 250,000, and Business at $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan.
9. FAQ
Can a screenshot prove a flight fare is still available?
No. It records what the page showed at capture time. Verify current availability and fare through the booking site.
Should an agent use a screenshot or an accessibility snapshot?
Use a screenshot to inspect appearance. Use an accessibility snapshot to understand page structure and interaction targets; use both when the task needs visual and structural context.
Does this method apply to every Indian flight booking website?
The Playwright capture mechanics are general, but this guide does not determine the terms or automation controls for any specific site. Check those independently.
When is an element capture better than a full-page capture?
When the task concerns one result or panel. It produces a focused image that is easier to compare and review.


