Skip to content
Python Proxy for html2canvas work with Django, Flask and CGI
Branch: master
Clone or download
Latest commit 6fd9cec Oct 3, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
flask Version 0.0.8 Dec 1, 2015
python-cgi Version 0.0.8 Dec 1, 2015
LICENSE 0.1.0 version Sep 30, 2017 Update Oct 3, 2017 Support to html2canvas-0.5.0-beta Sep 30, 2017

html2canvas-python-proxy 0.1.0

Python Proxy for html2canvas (tested in Python 2.7.3)

Although I have just added an example with "Flask" is library works with any "Python Web framework." Soon I'll add examples with other frameworks.

Others scripting language

You do not use PHP, but need html2canvas working with proxy, see other proxies:

Provisional documentation:

Module Description
html2canvasproxy([callback get param], [url get param]) Config html2canvasproxy
html2canvasproxy.enable_crossdomain() Enable the use of "Data URI scheme"
html2canvasproxy.useragent([user agent]) Config webbrowser user-agent
html2canvasproxy.hostname([url]) Config current URL (requires scheme and port)
html2canvasproxy.referer([referer]) Config referer page (If needed)
html2canvasproxy.route([real path], [virtual path]) Config "route" for images and real path (folder to save images). Note: "real path" is absolute path eg. /home/user/project1/images, "virtual path" should be as you want it to appear in the "address bar", eg. /images
html2canvasproxy.debug_vars() Get variables values for DEBUG
html2canvasproxy.result() Run proxy/Get response and mime-type by proxy.
html2canvasproxy.resource([real path], [image]) Get resource saved and mime-type by proxy "real path" is same in html2canvas.route([real path], [virtual path]). Read Get resources with proxy

How to use

A simple example of usage

from html2canvasproxy import * #Load html2canvasproxy

#Set GET variables
h2c = html2canvasproxy(request.args.get("callback"), request.args.get("url"))

#Uncomment next line to enable "data URI scheme" (optional)

#Set user-aget browser
if request.headers['user_agent']:

#Set current page

#Set referer (If needed)
if request.referer:

#Set route (real path and virtual path)
h2c.route('/home/guilherme/projects/site/images', '/images')

print 'Debug:'
print h2c.debug_vars()
print '---------'

result = h2c.result()

print 'mime: ' + result['mime']
print 'data: ' + result['data']
print '=========\n'

Get results with proxy

Run proxy/Get response and mime-type by proxy (returns application/javascript)

r = h2c.result()

print r['mime']
print r['data']

Get resources with proxy

Get resource saved and mime-type by proxy (returns images or html)

res = html2canvasproxy.resource(real_path, image)

print res['mime']
print res['data']
You can’t perform that action at this time.