Articles on: API

How to make screenshots?

You can get back a screenshot of the webpage you want to scrape by using the screenshot=True parameter.

You can find below how to do it:

Curl



curl "https://app.scrapingbee.com/api/v1/?api_key=YOUR-API-KEY&url=YOUR-URL&screenshot=True" > ./screenshot.png


Python


#  Install the Python ScrapingBee library:
# pip install scrapingbee

client = ScrapingBeeClient(api_key='YOUR-API-KEY')

response = client.get(
    'YOUR-URL',
    params={
        'screenshot': True,
    }
)

if response.ok:
    with open("./screenshot.png", "wb") as f:
        f.write(response.content)


Node



// npm install scrapingbee
const fs = require('fs');
const scrapingbee = require('scrapingbee');

async function screenshot(url, path) {
    var client = new scrapingbee.ScrapingBeeClient('YOUR-API-KEY');
    var response = await client.get({
        url: url,
        params: {
            screenshot: true, // Take a screenshot
            screenshot_full_page: true, // Specify that we need the full height
            window_width: 375, // Specify a mobile width in pixel
        }
    });

    fs.writeFileSync(path, response.data);
}

screenshot('YOUR-URL', './screenshot.png').catch((e) =>
    console.log('A problem occurs : ' + e.message)
);


You can read more about it here.

You can also use the full_page parameter to get a screenshot of the full page from the target website. You can read more about it here.

Updated on: 15/09/2021

Was this article helpful?

Share your feedback

Cancel

Thank you!