Skip to main content

Scrapfly Content Extractor & Screenshot Plugin

The Scrapfly plugin provides both screenshot capture and content extraction capabilities using the Scrapfly API. It handles JavaScript rendering, anti-bot bypass, and proxy rotation to access content from even heavily protected websites.

Source: packages/plugins/scrapfly/src/scrapfly.plugin.ts

Overview

PropertyValue
Plugin IDscrapfly
Package@ever-works/scrapfly-plugin
Categorycontent-extractor
Capabilitiesscreenshot, content-extractor
Version1.0.0
Configuration Modehybrid
Auto-enableNo
Built-inYes
System PluginNo

The plugin implements three interfaces: IPlugin, IScreenshotPlugin, and IContentExtractorPlugin. This dual-capability design means a single plugin and API key can serve both screenshot and content extraction needs.

Architecture

Configuration

Settings Schema

SettingTypeRequiredScopeDescription
apiKeystringYesuserScrapfly API key. Secret. Env: PLUGIN_SCRAPFLY_API_KEY

Environment Variables

VariableDescription
PLUGIN_SCRAPFLY_API_KEYScrapfly API key (optional -- can be set via admin/user settings)

Screenshot Capability

Capture Method

The capture() method takes a URL and returns a full-page screenshot:

const result = await scrapflyPlugin.capture({
url: 'https://example.com',
viewportWidth: 1280,
viewportHeight: 800,
delay: 2000, // Wait 2s before capture
waitForSelector: '.content', // Wait for element
settings: { apiKey: 'your-key' }
});

if (result.success) {
console.log(result.imageUrl); // Screenshot URL
console.log(result.width); // Viewport width
console.log(result.height); // Viewport height
console.log(result.fileSize); // File size in bytes
}

Screenshot Configuration

The plugin configures Scrapfly's ScrapeConfig with these settings:

ParameterValueDescription
render_jstrueJavaScript rendering enabled
rendering_waitFrom options.delayWait time before screenshot
wait_for_selectorFrom options.waitForSelectorCSS selector to wait for
screenshots{ main: 'fullpage' }Full-page screenshot
country'us'Request from US proxies

Maximum Dimensions

getMaxDimensions(): { width: number; height: number } {
return { width: 3840, height: 2160 };
}

Content Extraction Capability

Single URL Extraction

The extract() method scrapes a URL and returns markdown content:

const result = await scrapflyPlugin.extract({
url: 'https://example.com/article',
waitForJs: true, // Enable JS rendering (default: true)
settings: { apiKey: 'your-key' }
});

if (result.success) {
console.log(result.content); // Raw content
console.log(result.markdown); // Markdown formatted
console.log(result.wordCount); // Word count
console.log(result.readingTime); // Estimated reading time (minutes)
console.log(result.duration); // Extraction time (ms)
}

Extraction Configuration

ParameterValueDescription
render_jsFrom options.waitForJsJavaScript rendering (default: true)
asptrueAnti-Scraping Protection bypass
format'markdown'Output as markdown
country'us'Request from US proxies

Batch Extraction

The plugin supports batch extraction with concurrency control:

const results = await scrapflyPlugin.extractBatch(
['https://example.com/page1', 'https://example.com/page2', 'https://example.com/page3'],
{ settings: { apiKey: 'your-key' } }
);

Batch extraction processes URLs in groups of 5 with a 100ms delay between batches:

URL Validation

The canExtract() method checks if a URL is valid for extraction:

async canExtract(url: string): Promise<boolean> {
try {
const parsed = new URL(url);
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
} catch {
return false;
}
}

Only HTTP and HTTPS URLs are supported.

Key Features

FeatureDescription
Anti-Bot BypassHandles CAPTCHAs, JavaScript challenges, and bot detection
JavaScript RenderingFull browser rendering for SPAs and dynamic content
Full-Page ScreenshotsCaptures entire page, not just viewport
Markdown OutputContent extracted directly as markdown
Global Proxy NetworkAccess region-locked content from any country
Concurrent BatchingProcess multiple URLs in parallel batches

Lifecycle

Note that a new ScrapflyClient is created for each operation, using the API key from the request settings.

Dependencies

PackageVersionPurpose
scrapfly-sdk^0.7.3Official Scrapfly SDK
@ever-works/pluginworkspacePlugin contracts (peer dependency)

How It Works in Ever Works

Scrapfly serves dual purposes during work generation:

  1. Screenshot capture: Capturing preview images of work items (websites, products, etc.)
  2. Content extraction: Pulling text content from web pages to enrich item descriptions

Its anti-bot capabilities make it effective for scraping sites that block standard HTTP requests, such as e-commerce platforms and social media sites.

Getting Started

  1. Sign up at scrapfly.io
  2. Copy your API key from the dashboard
  3. Enable the Scrapfly plugin in Ever Works
  4. Enter the key in the API Key field
  5. The plugin is now available for both screenshot and content extraction tasks