Screenshot
Scraping Fish API allows you to retrieve the 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.
Example
To get the screenshot of example.com, send a request with screenshot=true
query parameter.
GET
/api/v1/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)
The resulting website screenshot will be returned as bytes. In the example above, it is saved to screenshot.png
file.
Screenshot with HTML content
To get a response with both screenshot and HTML content, specify screenshot_base64
query parameter and set it to true.
The response will be in JSON format and include two keys: content
and screenshot
.
The value of content
key will be the website HTML content whereas the value of screenshot
key will store base64-encoded screenshot image.
GET
/api/v1/import requests
payload = {
"api_key": "[your API key]",
"url": "https://www.example.com",
"screenshot_base64": True,
}
response = requests.get("https://scraping.narf.ai/api/v1/", params=payload)
print(response.json())
JSON response:
Response
{
"content": "<!DOCTYPE html><html><head>\n <title>Example Domain</title>...",
"screenshot": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAF1CAIAAADaxiG8AAAAAXNSR0..."
}