Package: screamshot
ScreamshotPython library to capture screenshots of web applicationsGood practicesAny code addition must be done in your own branch. You can name itfl/what_this_branch_bringswhere '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 checksTo start the tests and checksThe first timeInstalldockeranddocker-compose.Run:docker-compose build, to create all the required images.To start the verification, run:docker-compose up.When it is already setupYou just need to rundocker-compose up.To clean upIf 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 testsYou must use theunittestpackageYou must put your test file in thetestsfolderYou must name your test file using the following next pattern:test_*.pyLocal serverA server with a web page can be used at the following address:http://server:5000/index.htmlandhttp://server:5000/other.htmlUsageDocumentationThe documentation is accessiblehere, on readthedocs.Exemple with djangoThe 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 GunicornWithGunicornthere isn't the thread related problems so we don't need to use the --nothreading and --noreload arguments.CHANGELOG0.0.1Initialization of Screamshot libraryinitfile:authorversionallcore file:AScreenShotobject with three methods:load, loads a web pagescreamshot, takes a screenshot of a loaded pageload_and_screamshot, loads a web page and takes a screenshot0.1.0There is no moreScreenShotobject just a function namedgenerate_bytes_imgwhich
takes some parameters and returns a binarybytesobject.0.1.1generate_bytes_imgis no more a sync function andgenerate_bytes_img_promhas been addedgenerate_bytes_img_promuses theasyncio.Futureobject0.1.2A test and verification tool using Docker is now available0.1.3Addbrowser-managerscriptAddscreamshotscript0.1.4AddserializefunctionAdddeserializefunction0.1.5Addgenerate_bytes_img_django_wrapfunction0.1.6Module is now available0.1.7The browser endpoint is saved in the temporary directory0.1.8serializefunction returns adictobjectdeserializetakes adictobject0.1.9Remove serializer functionsAdd a bytes_to_img function0.1.10generate_bytes_img_django_wrapis renamedgenerate_bytes_img_wrapError are handled0.1.11bytes_to_pngis renamedbytes_to_filebytes_to_filesupports type choice0.1.12You can now fetch http headers from another page withget_tokenAnd store these headers in the local storage