AI Browser Agent: Scrape with Plain English
Scrayle's AI Agent controls a real browser, extracts data from plain English instructions, and converts sessions into editable workflows.
Writing CSS selectors and XPath expressions is the most tedious part of web scraping. Selectors break when sites redesign, class names are often auto-generated gibberish, and deeply nested DOM structures make targeting specific elements a game of trial and error. What if you could skip all of that and just tell an AI what data you want?
Scrayle's AI Browser Agent does exactly that. You describe your goal in plain English - "go to this URL and extract all product names, prices, and ratings" - and the AI takes over a real cloud browser session, navigates the page, figures out the right selectors, handles pagination, and returns structured data. When it's done, it automatically converts the entire interaction into a reusable, editable workflow that you can schedule and run forever.
How the AI Agent Works
The agent is not a simple wrapper around an LLM. It operates in a feedback loop with a real browser:
- You provide a natural language instruction like "Go to yelp.com, search for 'pizza' in Chicago, and extract the name, rating, review count, and address of the first 20 results."
- The agent launches a Scrayle cloud browser session and takes a screenshot of the initial page state. It analyzes the visual layout and DOM structure to plan its actions.
- It executes browser actions step by step - clicking elements, typing into search fields, scrolling, waiting for content to load. After each action, it takes another screenshot to verify the result and plan the next step.
- It identifies the target data by analyzing the rendered page, then generates CSS selectors (or falls back to XPath) to extract exactly the fields you asked for.
- It returns structured JSON with the extracted data, plus the complete list of actions it took as a reusable workflow definition.
The key difference from other AI scraping tools is that the agent works with a real browser, not a simplified HTML representation. It sees JavaScript-rendered content, can interact with SPAs, handle infinite scroll, dismiss cookie banners, and click through pagination - just like a human would.
Try It: Extracting Product Data
The AI Browser Agent runs inside the Scrayle dashboard - navigate to app.scrayle.com → Workflows → New AI Session. Describe your goal in plain English:
Go to https://books.toscrape.comExtract the first 20 books with:- title- price- star rating (as a number 1-5)- availability statusIf there is pagination, go to page 2 to get enough results.
The agent opens a real cloud browser, navigates the page, identifies the book listing grid, extracts data from each card, clicks the next button, collects more from page 2, and returns the combined results. The whole process typically takes 15-30 seconds. Once it finishes, the session is saved as a reusable workflow you can run via the SDK:
import { Scrayle } from '@scrayle/sdk';const client = new Scrayle({ apiKey: process.env.SCRAYLE_API_KEY });// Trigger a run of the workflow the agent generatedconst run = await client.workflows.run({workflowId: 'wf_x8k2m9', // Workflow ID shown in the dashboardworkflowName: 'Book Scraper',steps: [], // Step definitions are loaded from the saved workflowselfHeal: true,browserMode: 'stealth',});// Wait for the run to completeconst result = await client.workflows.waitForCompletion(run.taskId);console.log('Run status:', result.status);console.log('Steps completed:', Object.keys(result.stepResults ?? {}).length);
What the Output Looks Like
The dashboard displays the extracted data alongside the workflow steps the agent took. A typical run result looks like this:
{"status": "completed","stepResults": {"navigate-1": { "status": "done" },"extract-1": { "status": "done", "output": "20 items" },"click-1": { "status": "done" },"extract-2": { "status": "done", "output": "20 items" }}}
The dashboard also shows the scraped items in a structured table and lets you copy the generated workflow ID for use in the SDK.
The Auto-Generated Workflow
This is where things get powerful. The workflow object returned by the agent is not just metadata - it's a complete, executable workflow definition. You can:
- Run it again without the AI agent (faster and cheaper, since it uses deterministic selectors instead of AI reasoning)
- Edit it in the visual workflow builder to add/remove steps, change selectors, or modify the output format
- Schedule it to run on a cron expression (e.g., every Monday at 9 AM)
- Add data delivery - push results to a webhook, email, S3 bucket, or Scrayle's built-in storage
// Re-run the workflow without AI (uses saved step definitions)const run = await client.workflows.run({workflowId: 'wf_x8k2m9',workflowName: 'Book Scraper',steps: [],selfHeal: true,});const result = await client.workflows.waitForCompletion(run.taskId);console.log('Status:', result.status);// Scheduling and data delivery (webhook, email, storage) are// configured in the dashboard under Workflows -> Schedule.
When to Use the AI Agent vs. Manual Selectors
The AI agent adds latency and cost compared to a direct browser session with manual selectors. Here's when each approach makes sense:
Use the AI Agent when:
- You're scraping a new site and don't know the DOM structure yet
- The site uses randomly generated class names (common with CSS-in-JS frameworks)
- You need to interact with complex UI elements (dropdowns, modals, infinite scroll)
- You want a working scraper in minutes instead of hours
- You're building proof-of-concept scrapers to evaluate feasibility
Use manual Puppeteer/Selenium when:
- You already have working selectors for the target site
- Speed and cost efficiency are critical (high-volume production scraping)
- The page structure is simple and predictable
- You need precise control over every browser action
A common pattern is to use the AI agent for the initial setup, edit the generated workflow to optimize it, and then run the optimized version on a schedule. You get the speed of AI for development and the efficiency of deterministic execution for production.
Handling Complex Interactions
The AI agent can handle multi-step interactions that would be tedious to code manually. Here are some examples of instructions it can follow:
# Search and filterGo to amazon.comSearch for "mechanical keyboard"Filter by 4 stars and upSort by price low to highExtract the first 15 results with:- product name- price- rating- number of reviews- whether it has Prime shipping
# Login and navigateGo to linkedin.com/loginLog in with the saved credential "LinkedIn Recruiter"Navigate to the company page for "Scrayle"Extract all job listings with title, location, and posted date
# Multi-page data collectionGo to zillow.comSearch for homes for sale in "Austin, TX"Set price range to $300,000 - $500,000Extract the first 30 listings with:- address- price- beds, baths, sqft- listing agentNavigate through pages if needed to get 30 results
Self-Healing Selectors
One of the biggest advantages of using the AI agent is self-healing selectors. When a generated workflow runs and encounters a broken selector (because the site changed its markup), Scrayle detects the failure and automatically re-invokes the AI to update the selector. The workflow continues without interruption, and the updated selector is saved for future runs.
This means your scheduled scraping jobs don't silently break when a site pushes a redesign. Instead of receiving empty data and scrambling to fix selectors manually, the system heals itself. You'll see a notification in the dashboard showing what changed, but the data keeps flowing.
Live View: Watch the AI Work
When the Live View is enabled from the dashboard session panel, you can watch the AI agent control the browser in real-time. This is useful for:
- Debugging when the agent isn't finding the right data
- Understanding how the agent interprets your instructions
- Catching edge cases (e.g., the site shows a different layout for certain regions)
- Demonstrating the technology to stakeholders
The live view shows the browser viewport, a log of actions the AI is taking, and the data it's extracting in real-time. You can also use the dashboard's built-in browser viewer to connect to any active session.
Cost and Performance
AI agent sessions cost more than plain browser sessions because they include LLM reasoning on top of the browser time. Typical costs:
- Plain browser session: Billed per minute of browser time
- AI agent session: Browser time + a per-step AI reasoning fee
- Workflow re-run (no AI): Same as a plain browser session
The recommended workflow is: use the AI agent once to generate a workflow, then run the workflow for ongoing data collection. You only pay the AI premium during initial setup and when selectors need healing.
What's Next
- Learn about scheduled workflows and data delivery to automate your scraping pipelines end-to-end
- Read the getting started guide if you want more control with manual Puppeteer/Selenium sessions
- Explore the visual automation builder for a no-code approach to editing and managing workflows
Ready to try it? The free tier includes AI agent credits. Sign up at app.scrayle.com and run your first agent session in under a minute.
Related reading: