Skip to main content

Saizul Amin

AI

Building an Autonomous Data Extraction Pipeline with Playwright, Python, and Claude 3.5 Vision (2026 Tutorial)

📅 12 Aug 2026 ⏱ 2 min read
AI
In this article

    Overcoming the Fragility of Traditional Web Scrapers

    Traditional web scrapers break constantly because they depend on rigid CSS selectors, XPath expressions, or brittle HTML DOM structures. When target websites update class names, deploy dynamic React hydration wrappers, or introduce canvas-rendered elements, traditional scrapers fail completely. By combining Playwright browser automation with Claude 3.5 Sonnet multimodal vision reasoning, developers build self-healing scrapers that extract data visually just like a human operator.

    Authored by Saizul Amin for AI automation engineers and web intelligence specialists.

    Multimodal Extraction Architecture

    1. Headless Navigation: Playwright launches Chromium, navigates to the target URL, waits for network idle, and captures a full-page high-resolution screenshot.
    2. Vision Parsing: The screenshot is sent directly to Claude 3.5 Sonnet along with a target extraction schema (e.g., pricing, feature names, stock status).
    3. Structured Output: Claude analyzes visual layouts and outputs strictly valid JSON without touching raw HTML or obfuscated classes.
    4. Database Ingestion: n8n or Python persists the clean JSON payload into PostgreSQL.

    Python Implementation with Playwright and Anthropic API

    
    import asyncio
    import base64
    import json
    from playwright.async_api import async_playwright
    import anthropic
    
    client = anthropic.Anthropic()
    
    async def capture_page_screenshot(url: str, output_path: str = "page.png") -> str:
        async with async_playwright() as p:
            browser = await p.chromium.launch(headless=True)
            page = await browser.new_page(viewport={"width": 1440, "height": 900})
            await page.goto(url, wait_until="networkidle")
            screenshot_bytes = await page.screenshot(full_page=True)
            await browser.close()
            return base64.b64encode(screenshot_bytes).decode('\''utf-8'\'')
    
    def extract_pricing_visually(image_base64: str) -> dict:
        prompt = '\'''\'''\''Inspect this website screenshot and extract all pricing tiers.
    Return ONLY valid JSON matching:
    {
      "currency": string,
      "plans": [
        {"name": string, "price_monthly": number, "features": [string]}
      ]
    }'\'''\'''\''
    
        message = client.messages.create(
            model="claude-3-5-sonnet-20241022",
            max_tokens=1000,
            messages=[
                {
                    "role": "user",
                    "content": [
                        {
                            "type": "image",
                            "source": {
                                "type": "base64",
                                "media_type": "image/png",
                                "data": image_base64
                            }
                        },
                        {"type": "text", "text": prompt}
                    ]
                }
            ]
        )
        return json.loads(message.content[0].text)
    
    async def main():
        b64 = await capture_page_screenshot("https://example.com/pricing")
        data = extract_pricing_visually(b64)
        print(json.dumps(data, indent=2))
    
    if __name__ == "__main__":
        asyncio.run(main())
    

    Operational Advantages of Vision Scrapers

    • Immune to DOM Refactoring: Class name scramblers and shadow DOM trees do not degrade visual perception.
    • Handles Complex Canvas & SVG Graphs: Directly reads numbers and labels rendered inside HTML5 canvas charts.
    Share this article
    Md Saizul Amin
    Written by

    Digital Systems Strategist · AI Agent Developer · 9+ years in digital & IT

    Md Saizul Amin is a digital systems strategist and AI automation engineer from Dhaka, Bangladesh. With 9+ years across IT, web development and digital marketing, he writes practical guides on technology, business, education and online growth — and builds the same kinds of systems (AI agents, websites, SEO and ad campaigns) for clients in Bangladesh, the UK and the USA.

    9+Years in digital & IT
    50+Websites developed
    7Live AI agent systems
    $150K+Ad spend managed

    Specialist in

    AI agents & n8n automationLLM integration (Gemini, GPT-4o, Claude)Custom software & web appsWordPress developmentSEO · AEO · GEOMeta & Google AdsEmail deliverabilityCRM & funnelsIT infrastructure & cybersecurity

    Credentials & experience

    • 🎓
      B.Sc. in Computer Science & EngineeringBangladesh University of Business & Technology (BUBT), 2017–2021
    • 🤖
      AI Automation Engineer · Web Developer · SEO SpecialistUnique Mark Limited, Birmingham UK — 2024 to present
    • 🌱
      IT SpecialistGreen Fund Initiative Inc., USA — 2024 to present
    • 🏥
      Junior IT Consultant — Ministry of Health (DGHS)Built the first national Shareable Health Record website; supported 6,000+ facilities
    • 🧭
      Head of ITWEDO Bangladesh — led IT for 50+ staff, 2021–2023

    ✔ Researched and written by the author, informed by hands-on work on real projects. Articles are updated when facts, tools or guidelines change.

    Want results like this for your business?

    AI agents, custom software, websites and growth systems — let’s talk about yours.