Scrape Pages
Extract content from any webpage as Markdown, HTML, JSON, links, or screenshots. Scrayle handles JavaScript rendering, anti-bot protection, and content extraction automatically.
Basic Scrape
import { ScrayleClient } from '@scrayle/sdk';
const client = new ScrayleClient();
const result = await client.scrapingCrawl.scrapeUrl(
'https://example.com',
{ formats: ['markdown'] }
);
console.log(result.data?.markdown);Output Formats
| Format | Description |
|---|---|
markdown | Clean Markdown with headings, links, and text |
html | Cleaned HTML (scripts/styles removed) |
rawHtml | Original HTML as received |
links | Array of all links on the page |
screenshot | Base64-encoded screenshot |
json | Structured JSON extraction |
Multiple Formats
const result = await client.scrapingCrawl.scrapeUrl(
'https://example.com',
{ formats: ['markdown', 'links', 'screenshot'] }
);
console.log(result.data?.markdown);
console.log(result.data?.links); // string[]
console.log(result.data?.screenshot); // base64 stringScrape Options
| Option | Type | Description |
|---|---|---|
formats | string[] | Output formats to return |
headers | object | Custom request headers |
includeTags | string[] | Only include these HTML tags |
excludeTags | string[] | Exclude these HTML tags |
onlyMainContent | boolean | Strip nav, footer, sidebar |
timeout | number | Request timeout in ms |
waitFor | number | Wait ms after page load |
Content Filtering
const result = await client.scrapingCrawl.scrapeUrl(
'https://example.com/article',
{
formats: ['markdown'],
onlyMainContent: true, // Skip nav/footer/sidebar
excludeTags: ['img', 'svg'], // Skip images
waitFor: 2000, // Wait 2s for dynamic content
}
);Async Scraping
Start a scrape without waiting for the result:
// Start the scrape
const { id } = await client.scrapingCrawl.scrape.asyncScrapeUrl(
'https://example.com',
{ formats: ['markdown'] }
);
// Check status later
const status = await client.scrapingCrawl.scrape.checkScrapeStatus(id);
if (status.status === 'completed') {
console.log(status.data?.markdown);
}With AI Extraction
Extract structured data using AI:
const result = await client.scrapingCrawl.scrapeUrl(
'https://example.com/products',
{
formats: ['json'],
extract: {
prompt: 'Extract all product names and prices',
schema: {
type: 'object',
properties: {
products: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
price: { type: 'string' },
},
},
},
},
},
},
}
);
console.log(result.data?.json);💡Credits
Each scrape costs 1 credit.
Next Steps
- Batch Scraping - Scrape multiple URLs at once
- Crawl Websites - Follow links and scrape entire sites
- Universal Scraper - JavaScript rendering and web unlocking