Screenshot
Scraping Fish API allows you to retrieve a screenshot of a webpage as a PNG image file.
To do so, you need to provide the screenshot
query parameter and set it to true
.
note
When a screenshot is returned, no HTML content will be returned.
Example
To get a screenshot of the website example.com, you send a request with screenshot=true
query parameter.
- Python
- NodeJS
- cURL
import requests
payload = {
"api_key": "[your API key]",
"url": "https://www.example.com",
"screenshot": "true",
}
response = requests.get("https://scraping.narf.ai/api/v1/", params=payload)
with open("./screenshot.png", "wb") as f:
f.write(response.content)
const axios = require("axios");
const fs = require('fs');
const payload = {
api_key: "[your API key]",
url: "https://www.example.com",
screenshot: "true",
};
await axios.get(
"https://scraping.narf.ai/api/v1/",
{ params: payload, responseType: "arraybuffer" }
).then(response => {
fs.writeFileSync("./screenshot.png", Buffer.from(response.data));
})
curl -G --data-urlencode 'url=https://www.example.com' \
'https://scraping.narf.ai/api/v1/?api_key=[your API key]&screenshot=true' > ./screenshot.png
The resulting website screenshot will be saved to screenshot.png
.