Lesson 8 — Interact: Unlocking Interactive Webpages
Some websites require clicking buttons, scrolling down, or logging in to reveal content. Firecrawl's Interact feature allows you to control the scraping process just like operating a real browser.
8.1 The Interaction Workflow (Three Steps)
Unlike standard scraping, Interact requires maintaining a "browser session":
- Scrape (Create Session): Open the target page and obtain a
scrapeId. - Interact (Execute Actions): Send instructions (click, type, scroll, etc.) using the
scrapeId. - Interact Stop (Release Resources): Once operations are complete, you MUST stop the session to end billing.
8.2 Two Interaction Modes
1. Prompt Mode (AI-Driven)
Describe the actions you want to take using natural language.
Example:
"Type 'Firecrawl' in the search box and click the search button."Pros: Simple. Cons: AI might misunderstand complex DOM structures.
2. Code Mode (Precision Control)
Use specific agent-browser commands, ideal for deterministic operations.
Example:
agent-browser type @e3 "Firecrawl" && agent-browser click @e5.
8.3 Common Interaction Commands
| Command | Description |
|---|---|
click @selector |
Click an element (@e1, @e2 are IDs auto-labeled by Firecrawl) |
type @selector "text" |
Type text into an input field |
scroll down/up |
Scroll the page |
wait 2000 |
Wait (in milliseconds) |
screenshot |
Take a screenshot of the current state |
8.4 Practical Case: Scraping After Login
To fetch dashboard data that requires authentication:
- Scrape the login page.
- Interact: Enter username/password and click "Login."
- Interact: Wait for the redirect to complete, then perform data extraction.
- Interact Stop: Finish the task and release the session.
8.5 Important Reminders
- Billing: Interact mode is billed per browser-minute (2 credits/minute).
- Timeout: Sessions have an inactivity timeout. If no commands are sent for a while, the session will expire automatically.
- Stop Promptly: Always call
firecrawl_interact_stopwhen finished to prevent continuous Credit consumption until the mandatory timeout.