Skip to content

Mdbaizidtanvir/Capture-Webpage-Screenshot-API-Free-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Web Screenshot Capture API

This is a free API that allows you to capture a full-page screenshot of a webpage and get the image as a Base64-encoded string.

git clone https://github.com/Mdbaizidtanvir/Capture-Webpage-Screenshot-API-Free-.git

pip install -e .

python app.py 


API Documentation

Endpoint

POST /capture-webpage

css Copy code

Description

This API endpoint accepts a POST request with a JSON payload containing a URL. It returns a full-page screenshot of the webpage at the provided URL as a Base64-encoded string.

Request Parameters

The request should contain the following JSON parameter:

{
    "url": "https://example.com"
}
Response Format
The response will be a JSON object with the Base64-encoded screenshot image:

json
Copy code
{
    "base64_image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}
Errors
If the URL parameter is missing or invalid, the response will contain an error message:


{
    "error": "Invalid JSON or missing 'url' parameter"
}
Free Service
This API is completely free! You can use it to capture webpage screenshots without any cost.

How to Use
Python Example
You can use the Python requests library to interact with the API. Here is an example:

python

import requests

url = 'https://your-port/capture-webpage'
data = {
    'url': 'https://example.com'
}

response = requests.post(url, json=data)

if response.status_code == 200:
    print('Base64 Image:', response.json()['base64_image'])
else:
    print('Error:', response.json()['error'])
JavaScript Example
Here is how you can call the API using JavaScript 

const url = 'https://your-port/capture-webpage';
const data = {
    url: 'https://example.com'
};

fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
    if (data.base64_image) {
        console.log('Base64 Image:', data.base64_image);
    } else {
        console.error('Error:', data.error);
    }
})
.catch(error => console.error('Error:', error));


Credits
This project was created by Md Baizid Tanvir.

About

This is a free API that allows you to capture a full-page screenshot of a webpage and get the image as a Base64 πŸŽƒπŸŽƒ-encoded string.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors