Screenshot

overview page of web interface
Screenshot tab of log inspection
This feature require Javascript Rendering enabled

You can take multiple screenshots of a webpage. You have a choice between full page or specific zone via CSS selector.

The screenshot feature works beside the scraper, which means you can still scrape as usual and use the screenshot features. The upstream response is not altered with a screenshot.

Screenshots can help you to debug, track visual changes, and generate thumbnails of a website.

You can take a maximum of 10 different screenshots per scrape.

Usage

In this example, we take three screenshots. One full-page and two others via CSS selector

curl -G \
--request "GET" \
--url "https://api.scrapfly.io/scrape" \
--data-urlencode "key=__API_KEY__" \
--data-urlencode "url=https://www.amazon.fr/MikroTik-CRS305-1G-4S-Interrupteur-Ethernet-routerOS/dp/B07LFKGP1L" \
--data-urlencode "render_js=true" \
--data-urlencode "screenshots[full-page]=fullpage" \
--data-urlencode "screenshots[similarities]=.similarities-widget" \
--data-urlencode "screenshots[price]=#price"
"https://api.scrapfly.io/scrape?key=&url=https%253A%252F%252Fwww.amazon.fr%252FMikroTik-CRS305-1G-4S-Interrupteur-Ethernet-routerOS%252Fdp%252FB07LFKGP1L&render_js=true&screenshots%5Bfull-page%5D=fullpage&screenshots%5Bsimilarities%5D=.similarities-widget&screenshots%5Bprice%5D=%2523price"

key                        = "" 
url                        = "https://www.amazon.fr/MikroTik-CRS305-1G-4S-Interrupteur-Ethernet-routerOS/dp/B07LFKGP1L" 
render_js                  = "true" 
screenshots[full-page]     = "fullpage" 
screenshots[similarities]  = ".similarities-widget" 
screenshots[price]         = "#price" 

Example Of Response

{
    ...
    "result": {
        ...
        "screenshots": {
            "main": {
                "extension": "png",
                "format": "fullpage",
                "css_selector": null,
                "size": 2867974,
                "url": "https://scrapfly.io/4d1b8e8f-3803-4aa6-88fa-39d5aa81b6b3/scrape/screenshot/db475202-a7c0-4d7b-9179-98089901fce3/main"
            },
            "similarities": {
                "extension": "png",
                "format": "element",
                "css_selector": ".similarities-widget",
                "size": 109817,
                "url": "https://scrapfly.io/4d1b8e8f-3803-4aa6-88fa-39d5aa81b6b3/scrape/screenshot/db475202-a7c0-4d7b-9179-98089901fce3/similarities"
            },
            "price": {
                "extension": "png",
                "format": "element",
                "css_selector": "#price",
                "size": 10364,
                "url": "https://scrapfly.io/4d1b8e8f-3803-4aa6-88fa-39d5aa81b6b3/scrape/screenshot/db475202-a7c0-4d7b-9179-98089901fce3/price"
            }
        }
        ...
    }
    ...
}

All related errors are listed below. You can see full description and example of error response on Errors section

Limitations

This feature require javascript rendering to be enabled in order to work. In some situations, the screenshot system won't be able to take it. For many reasons:

  • Huge page : Require a large amount of memory - to keep our service stable, we prefer to shut down the rendering
  • Broken script : For unknown reason at the time, when web pages contain bugged / no well-scripted javascript, the rendering system might crash

In case of error API will return you error code : ERR::SCRAPE::UNABLE_TO_TAKE_SCREENSHOT

Integration