Skip to content

Smart Scraping

Fresh Source: docs.airtop.ai

The scrapeContent method extracts page content as clean markdown. It handles complex pages including Office365 documents, Google Docs, dynamically rendered content, and more.

Basic Usage

typescript
const result = await client.windows.scrapeContent(sessionId, windowId);
console.log(result.data.content); // Clean markdown string
python
result = client.windows.scrape_content(session_id, window_id)
print(result.data.content)  # Clean markdown string

With Output Schema

Extract structured data using a JSON schema.

typescript
const result = await client.windows.scrapeContent(sessionId, windowId, {
  config: {
    outputSchema: {
      type: 'object',
      properties: {
        title: { type: 'string' },
        author: { type: 'string' },
        publishDate: { type: 'string' },
        content: { type: 'string' },
        tags: { type: 'array', items: { type: 'string' } },
      },
    },
  },
});
const article = JSON.parse(result.data.content);
python
result = client.windows.scrape_content(session_id, window_id, config={
    "outputSchema": {
        "type": "object",
        "properties": {
            "title": {"type": "string"},
            "author": {"type": "string"},
            "publishDate": {"type": "string"},
            "content": {"type": "string"},
            "tags": {"type": "array", "items": {"type": "string"}}
        }
    }
})
import json
article = json.loads(result.data.content)

Supported Content Types

Content TypeNotes
Standard HTML pagesClean markdown extraction
JavaScript-rendered pagesWaits for dynamic content
Office365 documentsWord, Excel, PowerPoint online
Google Docs/Sheets/SlidesFull content extraction
PDF viewersExtracts text from embedded PDFs
SPAs (React, Vue, Angular)Renders and extracts

scrapeContent vs pageQuery

FeaturescrapeContentpageQuery
PurposeFull page extractionSpecific questions
OutputMarkdown (or JSON with schema)LLM-generated answer
Best forArchiving, indexing, full contentTargeted data points
CostLower (single extraction)Higher (LLM inference)

Best Practices

  1. Use for full content — when you need everything on the page
  2. Add output schema for structured extraction instead of raw markdown
  3. Wait for page load — ensure content is rendered before scraping
  4. Combine with pageQuery — scrape first for overview, query for specifics
  5. Handle large pages — very long pages may be truncated; use paginatedExtraction for multi-page content

Unofficial SOP documentation for Airtop