Interact examples
Login + extract
Authenticate and extract the dashboard
```bash
curl https://api.faircompany.ai/v1/crawl/interact \
-X POST \
-H "Authorization: Bearer fc_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/login",
"actions": [
{ "type": "fill", "selector": "#email", "value": "user@example.com" },
{ "type": "fill", "selector": "#password", "value": "super-secret" },
{ "type": "click", "selector": "button[type=\"submit\"]" },
{ "type": "wait_for_selector", "selector": ".dashboard", "timeout_ms": 10000 },
{ "type": "extract", "format": "markdown" }
]
}'
```
```ts
const session = await fc.interact({
url: "https://example.com/login",
actions: [
{ type: "fill", selector: "#email", value: "user@example.com" },
{ type: "fill", selector: "#password", value: "super-secret" },
{ type: "click", selector: 'button[type="submit"]' },
{ type: "wait_for_selector", selector: ".dashboard", timeout_ms: 10000 },
{ type: "extract", format: "markdown" },
],
});
console.log(session.profile_id);
console.log(session.markdown);
```
```python
session = fc.interact(
"https://example.com/login",
[
{"type": "fill", "selector": "#email", "value": "user@example.com"},
{"type": "fill", "selector": "#password", "value": "super-secret"},
{"type": "click", "selector": "button[type=\"submit\"]"},
{"type": "wait_for_selector", "selector": ".dashboard", "timeout_ms": 10000},
{"type": "extract", "format": "markdown"},
],
)
print(session.profile_id)
print(session.markdown)
```
```json
{
"tool": "faircrawl_interact",
"arguments": {
"url": "https://example.com/login",
"actions": [
{ "type": "fill", "selector": "#email", "value": "user@example.com" },
{ "type": "fill", "selector": "#password", "value": "super-secret" },
{ "type": "click", "selector": "button[type=\"submit\"]" },
{ "type": "wait_for_selector", "selector": ".dashboard", "timeout_ms": 10000 },
{ "type": "extract", "format": "markdown" }
]
}
}
```
SPA scroll
curl https://api.faircompany.ai/v1/crawl/interact \ -X POST \ -H "Authorization: Bearer $FAIRCRAWL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/feed", "actions": [ { "type": "scroll", "amount": 1800 }, { "type": "wait", "ms": 1200 }, { "type": "extract", "format": "markdown" } ] }'Form submission
Swap the final extract for screenshot if you need proof of the submitted state rather than readable text.