Skip to main content

Python library to capture screenshots of web applications or pages

Project description

[![Build Status](](
[![Coverage Status](](
[![Documentation Status](](
[![PyPI version](](
# Screamshot
Python library to capture screenshots of web applications

## Good practices

* Any code addition must be done in your own branch. You can name it `fl/what_this_branch_brings` where 'f' is the first letter of your first name and 'l' the first letter of your last name.
* A branch resolves a specific issue.
* Please write exhaustive tests. The coverage must not decrease.
* Please merge the master branch into yours, run the tests and checks and correct all errors and warnings before pushing your code.
* When you think you have finished you can make a pull request.

## Testing and checks
### To start the tests and checks
#### The first time

1. Install **docker** and **docker-compose**.
2. Run: `docker-compose build`, to create all the required images.
3. To start the verification, run: `docker-compose up`.

#### When it is already setup

You just need to run `docker-compose up`.

#### To clean up

* If you want to stop containers and remove containers, networks, volumes, and images created by up command, run: `docker-compose down`.
* If you want to delete all the images, run: `docker rmi -f $(docker images -q)`.

### To write new tests

* You must use the `unittest` package
* You must put your test file in the **tests** folder
* You must name your test file using the following next pattern: **test_*.py**

#### Local server

A server with a web page can be used at the following address: <http://server:5000/index.html> and <http://server:5000/other.html>

## Usage
### Documentation

The documentation is accessible [here](, on readthedocs.

### Exemple with django

The server must be launched using --nothreading and --noreload as argument.
# in a Django project
from django.http import HttpResponse

import asyncio

from screamshot import generate_bytes_img_prom

def home(request):
loop = asyncio.get_event_loop()
future = asyncio.Future()

generate_bytes_img_prom('', future))

return HttpResponse(future.result(), content_type='image')
Or using the already wrapped function
# in a Django project
from django.http import HttpResponse

from screamshot import generate_bytes_img__django_wrap

def home(request):
img = generate_bytes_img__django_wrap('')
return HttpResponse(img, content_type='image')

#### Using Gunicorn

With [Gunicorn]( there isn't the thread related problems so we don't need to use the --nothreading and --noreload arguments.



Initialization of Screamshot library
1. __init__ file:
* __author__
* __version__
* __all__
2. core file:
* A `ScreenShot` object with three methods:
* `load`, loads a web page
* `screamshot`, takes a screenshot of a loaded page
* `load_and_screamshot`, loads a web page and takes a screenshot


There is no more `ScreenShot` object just a function named `generate_bytes_img` which
takes some parameters and returns a binary `bytes` object.


`generate_bytes_img` is no more a sync function and `generate_bytes_img_prom` has been added
`generate_bytes_img_prom` uses the `asyncio.Future` object


A test and verification tool using Docker is now available


Add two commands:
* `browser-manager`
* `screamshot`


Add two functions:
* `serialize`
* `deserialize`


Add `generate_bytes_img_django_wrap` function


Module is now available

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for screamshot, version 0.1.6
Filename, size File type Python version Upload date Hashes
Filename, size screamshot-0.1.6-py3-none-any.whl (11.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size screamshot-0.1.6.tar.gz (9.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page