Screenshot

Scrapfly's screenshot feature allows capturing a screenshot of the scraped web page. These screenshots can be full page or focused on specific HTML elements via CSS selectors.

Screenshots feature requires Javascript Rendering enabled

Captured screenshots are stored on Scrapfly's servers and the URLs are available in the API response under result.screenshots key as well as monitoring logs Screenshot tab:

screenshot details on the monitoring logs page

The screenshots feature is a great way to understand what is happening during a scrape. It can be used to debug a scraper or to monitor a website for visual changes.

Note that Scrapfly headless browsers are optimized for web scraping and do not render media files like images or videos, so they will not appear in the screenshots. If you need to render images in screenshot, you must enable the flag screenshot_flags=load_images, see flags section for more information.

The screenshot feature works beside the scraper and does not affect or alter the scraped result.

A maximum number of 10 different screenshots can be taken per single scrape.

Usage

To use the screenshots feature the screenshots parameter must be set with a screenshot name and the desired capture area:

For example, to capture the full page and the reviews section of this mock product page http://web-scraping.dev/product/1 we'd use two screenshot parameters:

curl -G \
--request "GET" \
--url "http://api.scrapfly.io/scrape" \
--data-urlencode "render_js=true" \
--data-urlencode "screenshots[all]=fullpage" \
--data-urlencode "screenshots[reviews]=#reviews" \
--data-urlencode "key=__API_KEY__" \
--data-urlencode "url=http://web-scraping.dev/product/1"
http://api.scrapfly.io/scrape?render_js=true&screenshots%5Ball%5D=fullpage&screenshots%5Breviews%5D=%2523reviews&key=&url=http%253A%252F%252Fweb-scraping.dev%252Fproduct%252F1

Example Of Response

Download Programmatically

The URL to download the screenshot is located in the response result.screenshots.${name}.url key. However, this URL requires authentication and to view it the key parameter must be added with your Scrapfly key. For example using curl:

curl "http://api.scrapfly.io/4d1b8e8f-3803-4aa6-88fa-39d5aa81b6b3/scrape/screenshot/db475202-a7c0-4d7b-9179-98089901fce3/main?key=" > screenshot.jpg

All related errors are listed below. You can see the full description and examples of error responses in Errors documentation page.

Options / Flags

You can enable additional options for the screenshot feature by adding the screenshot_flags parameter to the scrape request. You can set multiple flags by separating them with a comma. Here is the list of supported flags:

Example

curl -G \
--request "GET" \
--url "http://api.scrapfly.io/scrape" \
--data-urlencode "render_js=true" \
--data-urlencode "screenshots[all]=fullpage" \
--data-urlencode "screenshots[reviews]=#reviews" \
--data-urlencode "screenshot_flags=load_images,block_banners,high_quality" \
--data-urlencode "key=__API_KEY__" \
--data-urlencode "url=http://web-scraping.dev/product/1"
http://api.scrapfly.io/scrape?render_js=true&screenshots%5Ball%5D=fullpage&screenshots%5Breviews%5D=%2523reviews&screenshot_flags=load_images%252Cblock_banners%252Chigh_quality&key=&url=http%253A%252F%252Fweb-scraping.dev%252Fproduct%252F1

Limitations

The screenshots feature requires javascript rendering to be enabled. The screenshot capture can fail or be ignored in these situations:

Frequently Asked Questions

Integration