Documentation Index
Fetch the complete documentation index at: https://mintlify.com/firecrawl/firecrawl/llms.txt
Use this file to discover all available pages before exploring further.
Actions allow you to interact with a web page before scraping its content. This is useful for:
- Clicking “Load More” buttons to reveal additional content
- Filling out forms and logging in
- Scrolling to trigger lazy-loaded content
- Taking screenshots at different stages of interaction
- Executing custom JavaScript
Available Actions
Actions are executed sequentially in the order they are provided. Each action is performed before the final scrape.
Wait
Pause execution for a specified amount of time or until an element appears.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
# Wait for 2 seconds
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "wait", "milliseconds": 2000}
]
)
# Wait for a specific element to appear
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "wait", "selector": "#content-loaded"}
]
)
Click
Click on an element identified by a CSS selector.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
# Click a single button
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "click", "selector": "#load-more-button"},
{"type": "wait", "milliseconds": 1000}
]
)
# Click all matching elements
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "click", "selector": ".expand-button", "all": True}
]
)
Set "all": true to click all elements matching the selector. This is useful for expanding multiple sections at once.
Write
Type text into input fields, text areas, or contenteditable elements.
You must first focus the element using a ‘click’ action before writing. The text will be typed character by character to simulate keyboard input.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
doc = app.scrape(
url="https://example.com/login",
formats=["markdown"],
actions=[
{"type": "write", "text": "user@example.com"},
{"type": "press", "key": "Tab"},
{"type": "write", "text": "password"},
{"type": "click", "selector": 'button[type="submit"]'},
{"type": "wait", "milliseconds": 2000}
]
)
Press
Press a keyboard key. Useful for navigation, submitting forms, or triggering keyboard shortcuts.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "press", "key": "Enter"},
{"type": "wait", "milliseconds": 1000}
]
)
Scroll the page or a specific element to reveal lazy-loaded content.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
# Scroll the entire page down
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "scroll", "direction": "down"},
{"type": "wait", "milliseconds": 1000}
]
)
# Scroll a specific element
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "scroll", "direction": "down", "selector": "#scrollable-div"}
]
)
Screenshot
Take a screenshot during action execution. Screenshots are returned in the response’s actions.screenshots array.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "screenshot"}, # Viewport screenshot
{"type": "click", "selector": "#show-modal"},
{"type": "wait", "milliseconds": 500},
{"type": "screenshot", "fullPage": True} # Full page screenshot
]
)
# Access screenshots from the response
if doc.actions and doc.actions.get('screenshots'):
for i, screenshot_url in enumerate(doc.actions['screenshots']):
print(f"Screenshot {i}: {screenshot_url}")
Scrape
Scrape the current page content during action execution. Results are returned in the response’s actions.scrapes array.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{"type": "scrape"}, # Scrape initial state
{"type": "click", "selector": "#load-more"},
{"type": "wait", "milliseconds": 1000},
{"type": "scrape"} # Scrape after loading more content
]
)
# Access intermediate scrapes
if doc.actions and doc.actions.get('scrapes'):
for i, scrape in enumerate(doc.actions['scrapes']):
print(f"Scrape {i} URL: {scrape['url']}")
print(f"HTML length: {len(scrape['html'])}")
Execute JavaScript
Execute custom JavaScript code on the page. The return value is available in the response’s actions.javascriptReturns array.
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
doc = app.scrape(
url="https://example.com",
formats=["markdown"],
actions=[
{
"type": "executeJavascript",
"script": "document.querySelector('.hidden-content').style.display = 'block';"
},
{"type": "wait", "milliseconds": 500}
]
)
Complete Example: Login Flow
Here’s a complete example showing how to combine multiple actions to log into a website:
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")
doc = app.scrape(
url="https://example.com/login",
formats=["markdown"],
actions=[
{"type": "write", "text": "user@example.com"},
{"type": "press", "key": "Tab"},
{"type": "write", "text": "password"},
{"type": "click", "selector": 'button[type="submit"]'},
{"type": "wait", "milliseconds": 2000},
{"type": "screenshot"}
]
)
print(doc.markdown)
Best Practices
Add wait times between actions: Pages need time to respond to interactions. Add wait actions with appropriate delays after clicks, scrolls, or form submissions.
Use specific selectors: Be as specific as possible with CSS selectors to ensure you’re targeting the correct elements. Use IDs when available.
Test action sequences: Test your action sequences in a browser’s developer tools first to ensure they work as expected.
Using actions with sensitive data (like login credentials) will set storeInCache to false automatically for security purposes.