Skip to main content

Python library to capture screenshots of web applications or pages

Project description

[![Build Status](https://travis-ci.org/makinacorpus/screamshot.svg?branch=master)](https://travis-ci.org/makinacorpus/screamshot)
[![Coverage Status](https://coveralls.io/repos/github/makinacorpus/screamshot/badge.svg?branch=master&service=github)](https://coveralls.io/github/makinacorpus/screamshot?branch=master&service=github)
[![Documentation Status](https://readthedocs.org/projects/screamshot/badge/?version=latest)](https://screamshot.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/screamshot.svg)](https://badge.fury.io/py/screamshot)
![Python version](https://img.shields.io/badge/Python-3.6-blue.svg?style=flat&logo=appveyor)
# 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](https://screamshot.readthedocs.io/en/latest/), on readthedocs.


### Exemple with django

The server must be launched using --nothreading and --noreload as argument.
```
# views.py 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()

asyncio.ensure_future(
generate_bytes_img_prom('https://www.google.fr', future))
loop.run_until_complete(future)

return HttpResponse(future.result(), content_type='image')
```
Or using the already wrapped function
```
# views.py 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('https://www.google.fr')
return HttpResponse(img, content_type='image')
```


#### Using Gunicorn

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


CHANGELOG
=========

0.0.1
===

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

0.1.0
===

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

0.1.1
===

`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

0.1.2
===

A test and verification tool using Docker is now available

0.1.3
===

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

0.1.4
===

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

0.1.5
===

Add `generate_bytes_img_django_wrap` function

0.1.6
===

Module is now available

0.1.7
===

From now on the browser endpoint is saved in the temporary directory

0.1.8
===

From now on `serialize` function returns a `dict` object and `deserialize` takes a `dict` object

0.1.9
===

Remove serializer functions and add a bytes_to_img function


Project details


Download files

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

Source Distribution

screamshot-0.1.9.tar.gz (9.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

screamshot-0.1.9-py3.7.egg (10.6 kB view details)

Uploaded Egg

screamshot-0.1.9-py3.6.egg (16.6 kB view details)

Uploaded Egg

screamshot-0.1.9-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file screamshot-0.1.9.tar.gz.

File metadata

  • Download URL: screamshot-0.1.9.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for screamshot-0.1.9.tar.gz
Algorithm Hash digest
SHA256 d0255e3751a54a5ff3af952583bd82cca1c3e6cd9bc57a474c4c0f6773f7fd4c
MD5 90aadcbfb266060dcf9e2ebf3545689f
BLAKE2b-256 c959bd9f114ea3890bf1cd48a66496c4c4e57ab4788dd75af2bb6894e42fd62d

See more details on using hashes here.

File details

Details for the file screamshot-0.1.9-py3.7.egg.

File metadata

  • Download URL: screamshot-0.1.9-py3.7.egg
  • Upload date:
  • Size: 10.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for screamshot-0.1.9-py3.7.egg
Algorithm Hash digest
SHA256 3bd84ae91a1253df39fbbef4d61cb4ba31921bde799a20f9a9eb7d516bc99325
MD5 8dd24b0255a9f47b7b3a7413e262bdf0
BLAKE2b-256 a31e96ce9b3f8982b75acb30800b5740f7642fcda94e953f12374b7277b0c507

See more details on using hashes here.

File details

Details for the file screamshot-0.1.9-py3.6.egg.

File metadata

  • Download URL: screamshot-0.1.9-py3.6.egg
  • Upload date:
  • Size: 16.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for screamshot-0.1.9-py3.6.egg
Algorithm Hash digest
SHA256 39514a6df3b1991d57b9fc8ecdbbcc2b06a034a261d596006c959b759239388b
MD5 b8e3c59d9e93f2321f809e7cbb47cfb8
BLAKE2b-256 1b1deb14b2abd8f2eeb5ff5646cdbc037f97e4235caa71e54cef799a1cebd9d0

See more details on using hashes here.

File details

Details for the file screamshot-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: screamshot-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for screamshot-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1595ed1983a43e4bfe5fc9a438bdf07c030d56c82463408f9eba375f7f977370
MD5 04bb630500cf952b0cb59fe3c90a5e2a
BLAKE2b-256 34bc416f8b7dd0f8cb7273f7779dd151b9079af0412f67613736930be971918c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page