adamn / python-webkit2png Goto Github PK
View Code? Open in Web Editor NEWPython script that takes screenshots (browsershots) using webkit
License: Other
Python script that takes screenshots (browsershots) using webkit
License: Other
would be nice
I've fount that no css was applied to rendered image during trying to use webkit2png on Fedora 12,13
example of weird rendering of http://vkontake.ru/
http://picasaweb.google.ru/lh/photo/honDOoOnQU3XJRHxMICQFXCXUK8LZseregIVfxT4Z60?feat=directlink
but I've found that http://www.csszengarden.com/ is rendering well...
Hi,
For getting screenshots of certain web pages with a following command;
webkit2png https://forecast.io/#/f/40.4344,-80.0248 -D ~/Desktop
then, I get this message,
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
Temporary exceptions can be configured via your app's Info.plist file.
To get around this, which apps' info.plist do I have to change ? I am using OS X 10.11.1
Thanks in advance.
Downloading/unpacking webkit2png
Downloading webkit2png-0.8.2.tar.gz
Saved /tmp/webkit2png-0.8.2.tar.gz
Running setup.py (path:/tmp/pip_build_root/webkit2png/setup.py) egg_info for package webkit2png
Successfully downloaded webkit2png
Cleaning up...
webkit2png-0.8.2/
webkit2png-0.8.2/PKG-INFO
webkit2png-0.8.2/setup.cfg
webkit2png-0.8.2/._setup.py
webkit2png-0.8.2/setup.py
webkit2png-0.8.2/webkit2png.egg-info/
webkit2png-0.8.2/webkit2png.egg-info/dependency_links.txt
webkit2png-0.8.2/webkit2png.egg-info/PKG-INFO
webkit2png-0.8.2/webkit2png.egg-info/SOURCES.txt
webkit2png-0.8.2/webkit2png.egg-info/top_level.txt
I would need to go through authentication for some specific captures. Indeed, on some documents / web pages, I need to be identified to view the document:
Some examples
Is it possible to
Hi,
I integrated this into my project but the script seems to hang with following urls:
http://www.threadless.com/
http://www.luisaviaroma.com/
http://www.shopnastygal.com/
If you have a solution for these I would love to hear about it. Until then I might need a manual backup for these.
-Jori
I've written a little snippet like you suggested in another thread. It's a method on a Django model class. I'm on the latest Ubuntu. (FWIW, it would be very helpful to see an example of how someone could script your excellent module to loop through a dozen urls and snap them all.)
def get_screenshot(self):
print "Getting screenshot for %s" % self
# fire it up
app = init_qtgui()
renderer = WebkitRenderer()
renderer.format = 'png'
# set the path
path = os.path.join(settings.SCREENSHOT_PATH, '%s.png' % self.slug)
# save it
out = open(path, "w")
renderer.render_to_file(self.url, out)
out.close()
It works fine when I run it once. Or every once in a while. But if I run it repeatedly I start to get bizarre segmentation faults and long trackbacks like this guy describes with a different PyQt app.
http://stackoverflow.com/questions/5923845/how-do-i-shut-down-pyqts-qtapplication-correctly
Here's an example:
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(:21953): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
Application asked to unregister timer 0xb000003 which is not registered in this thread. Fix application.
QObject::connect: Cannot connect (null)::configurationAdded(QNetworkConfiguration) to QNetworkConfigurationManager::configurationAdded(QNetworkConfiguration)
QObject::connect: Cannot connect (null)::configurationRemoved(QNetworkConfiguration) to QNetworkConfigurationManager::configurationRemoved(QNetworkConfiguration)
QObject::connect: Cannot connect (null)::configurationUpdateComplete() to QNetworkConfigurationManager::updateCompleted()
QObject::connect: Cannot connect (null)::onlineStateChanged(bool) to QNetworkConfigurationManager::onlineStateChanged(bool)
QObject::connect: Cannot connect (null)::configurationChanged(QNetworkConfiguration) to QNetworkConfigurationManager::configurationChanged(QNetworkConfiguration)
I used pip install webkit2png
to install.
It looks like installed successful.
However, when I tried to run scripts/webkit2png -h
I got this,
$ python: can't open file 'scripts/webkit2png': [Errno 2] No such file or directory
Some info you might wanna know,
Is there a document or a demo?
I don't know how to use it.
Currently, the output is rendered as it appears on screen. Would it be possible to somehow render a document with transparent background? I tried to mock about with the source my self, but I don't know Qt very well, so it's a bit overwhelming.
I was not able to generate an image using webkit blur filter? did i missed something?
You could add somewhere on README that if virtualenv
is used, it must be created using --system-site-packages
otherwise python doesn't have access to PyQt4
lib and error is shown.
virtualenv env --system-site-packages
Spent lot of time wondering why even after installing all the dependencies i got error when running webkit2png
>>> from PyQt4.QtCore import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4.QtCore
Hi I'm trying to screenshot a website in a different language the font appears as blocks instead of the actual characters is there a way to fix this? Here is an example url http://www.sun.mv/
Trying to run this silently in the background on my desktop.
Whenever JavaScript alert is called - webkit2png freezes in processEvents loop.
It's the same for prompt and confirm "pop-ups".
trying to install webkit2png using pip doesn't work at all in the setup.py there is a spurious reference to the github-cli:
package_dir = {'webkit2png': 'webkit2png'},
entry_points="""
[console_scripts]
ghi = github.issues:main
The script should be able to be called as a library in addition to the command line.
Using Python 2.6.5 on Ubuntu, the install instructions do not work - there is no such program as 'pip'.
Manually downloading webkit2png-0.8.2.tar.gz and running python setup.py install does not work - there is no such module as 'setuptools'.
I tried 'apt-get install python-pip' but it didn't help.
The tar file doesn't actually seem to contain any code anyway!
Weird problem, when _WebkitRendererHelper's init is called, I get "AttributeError: qWebSettings".
This seems to be because "self.dict.update(parent.dict)" is failing for some strange reason.
If I set "self._page.settings()" manually (by changing the code), I instead get "AttributeError: width".
The really strange part is if I add a line "print self.dict" in _WebkitRendererHelper it all looks correct, yet the object cannot find it's own attributes!
This is on Ubuntu Hardy running Python 2.5.2
I am trying to install using "Manual installation via Git" but getting this error
running install
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
creating webkit2png.egg-info
writing webkit2png.egg-info/PKG-INFO
writing top-level names to webkit2png.egg-info/top_level.txt
writing dependency_links to webkit2png.egg-info/dependency_links.txt
writing entry points to webkit2png.egg-info/entry_points.txt
writing manifest file 'webkit2png.egg-info/SOURCES.txt'
warning: manifest_maker: standard file 'setup.py' not found
error: package directory 'webkit2png' does not exist
Can somebody help me to install it ?
Posting this at your request. When the lgpl pyside bindings make the Ubuntu repositories will you use them and the LGPL?
Code:
import subprocess
subprocess.Popen('webkit2png.py -x 800 600 -o test.png http://google.com', shell=True)
This results in an empty 2.1kb image.
Is there some other way I should be calling webkit2png to process a large batch of urls?
First thanks very much for the code!!! Works great for single/manual captures but....
I am executing the code on OSX Yosemite.
If I force focus to the python-QT app by clicking its window BEFORE the "screen shot" is captured it works perfectly BUT if I simply launch the webkit2png script from my terminal app and DO NOT force focus to python-QT, the terminal app (currently in the foreground) is actually included as part of the generated screen capture.
This prevents me from using the app in an automated fashion to capture a list of URLs. Is it possible to programmatically force focus?
Thanks again!
webkit2png doesn't appear to capture images on sites that only load images when scrolled down.
A good example is: http://www.huffingtonpost.com/
Here is the (truncated) version that webkit2png captures:
And here is the (truncated) version that the Chrome extension Awesome Screenshot captures:
I'm not sure if there is a workaround for this, or if this is by design (to not capture all images), but it would be nice if there was a command line option to do so.
In the reference of QUrl(), it reads: % will be changed to %25... Then if the $url has %20 in it, it will be translate to %2520.. which is very confused.
Any way to prevent this?
Probably it works as intended but when you have plugins, like websites made entirely in flash, the webkit2png exits much sooner as it is needed for flash to load all the data and display the rendered content. So you end up with progress bars instead of oh-so-gorgeous website.
I've found that this works for me. In the waiting while:
while time.time() < waitToTime and QApplication.hasPendingEvents():
QApplication.processEvents()
seems like plugins have no events to report so changing it to:
while time.time() < waitToTime:
if QApplication.hasPendingEvents():
QApplication.processEvents()
seems not to brake anything and to force the waiting the exact number of seconds as requested.
I am having the same exact issue this guy is having:
http://www.blogs.uni-osnabrueck.de/rotapken/2008/12/03/create-screenshots-of-a-web-page-using-python-and-qtwebkit/#comment-922
I can use the webkit2png-simple.py script, but web2png.py is failing on all pages for me. I am also using Debian Lenny, and I suspected it may be something to do with the way Qt4 installs under aptitude, but I couldn't get it working with source compiles either.
sudo ./webkit2png.py -x -g 200 200 -o google.png -t 30 'http://www.google.com/'
Roland's suggestion (http://www.blogs.uni-osnabrueck.de/rotapken/2008/12/03/create-screenshots-of-a-web-page-using-python-and-qtwebkit/#comment-934) makes the script hang indefinitely. I've tried modifying the script myself, but I have only come up with blank renders, "failure to load" messages, or indefinite hanging.
webkit2png.log says:
ERROR:root:Failed to load http://www.google.com/
It not clear that it using whether GPL or LGPL(setup.py said)
even the version of license couldn't be found.
webkit2png run and I get the following :
webkit2png: cannot connect to X server.
you need to have a window manager running?
Following the "Manual installation via Git" instructions, the last step:
Install with: python python-webkit2png/setup.py install
returns:
sudo python python-webkit2png/setup.py install
running install
running bdist_egg
running egg_info
writing webkit2png.egg-info/PKG-INFO
writing top-level names to webkit2png.egg-info/top_level.txt
writing dependency_links to webkit2png.egg-info/dependency_links.txt
writing entry points to webkit2png.egg-info/entry_points.txt
warning: manifest_maker: standard file 'setup.py' not found
error: package directory 'webkit2png' does not exist
If I cd into the directory and run setup from there it works.
There is an error raised if one uses the --debug flag, due to the lines below.
if options.debug:
logger.basicConfig(level=logger.DEBUG)
I made a fork and fixed that error and another. That can be found here http://github.com/goosemo/python-webkit2png/commit/9161eb3bcb74b42fdb93350a6015d9c4ccace004
Great tool! Just one thing.
I'm rendering my website to png file. In my website, I use Monospaced Font so that "-" and "A,C,G,T" have the same width. Yet when I render my website to png using webkit2png, it gives me quite ugly looking because of the Monospaced Font problem.
How to solve it?
Thanks.
Hi, i installed the script properly (oh well, i guess…) and i can run it and see -help. but when i try to get a screenshot from a webpage, i get this error: "webkit2png: cannot connect to X server"…
any help? : /
Hi,
I came across this package as I'm wanting to be able to take a screenshot of a website from a URL and then extract a color palette from that image. I'm using django on a site now that already extracts color palettes from images, I just need the functionality so that I can take screenshots when a user enters a URL. Would I be able to do that with this package?
I set this up on a headless machine running Ubuntu, and I can't exactly sort out how to get it to read the SWF files on the page
Latest code changes are from 2 years ago, latest update on pypi is 7 years ago and broken since then, open PRs fixing issues do not get any feedback or get merged, issues do not get answers from the project owner.
So, is there hope that this project will be maintained in the future? Would it help if there are more contributions (reviews on PRs etc)?
How can I set the image quality?
I'm making browsershots with png extension, but the text quality on rendered html is low.
Hello,
i have problem with quality of image after using --scale= function.
For example, if i use command
python scripts/webkit2png --aspect-ratio=crop -scale=140 90 -d localhost:2.0 -o github_small.png http://www.github.com
I receive image in poor quality. How can I change quality of image?
Here is the command I am trying to run to generate screenshot, and it is throwing some strange errors
deploy:~$ DISPLAY=:99.0 webkit2png http://www.google.com -x 500 250
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/webkit2png/scripts.py", line 203, in __main_qt
TypeError: render_to_file() got an unexpected keyword argument 'url'
It throws the same error even after running the following command
deploy:~$ xvfb-run --server-args="-screen 0 1024x768x24" python /usr/local/bin/webkit2png -o google.png http://www.google.com/
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/webkit2png/scripts.py", line 203, in __main_qt
TypeError: render_to_file() got an unexpected keyword argument 'url'
Any ideas, what I may be doing wrong ?
Installing version 0.8.2 doesn't seem to install the webkit2png.py script (or any actual code, for that manner):
abeld@carbon:0:~$ virtualenv test
New python executable in test/bin/python
Installing setuptools, pip...done.
abeld@carbon:0:~$ source env/bin/activate
bash: env/bin/activate: No such file or directory
abeld@carbon:1:~$ source test/bin/activate
(test)abeld@carbon:0:~$ pip install webkit2png
Downloading/unpacking webkit2png
Using download cache from /home/abeld/.pip_download_cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fw%2Fwebkit2png%2Fwebkit2png-0.8.2.tar.gz
Running setup.py (path:/home/abeld/test/build/webkit2png/setup.py) egg_info for package webkit2png
Installing collected packages: webkit2png
Running setup.py install for webkit2png
Successfully installed webkit2png
Cleaning up...
(test)abeld@carbon:0:~$ ls -R test | grep webkit
webkit2png-0.8.2-py2.7.egg-info
test/lib/python2.7/site-packages/webkit2png-0.8.2-py2.7.egg-info:
(test)abeld@carbon:0:~$
tl;dr -- "-x" works, "--xvfb" doesn't.
If I instantiate using:
./webkit2png.py --debug --log=arse.log --xvfb=1024 768 http://example.com
the resulting xvfb run command is repeating instantations of xvfb-run strings:
DEBUG:webkit2png:Executing xvfb-run --auto-servernum --server-num 1014620 --server-args=-screen 0, 1024x768x24 ./webkit2png.py --debug --log=arse.log --xvfb=1024 768 http://example.com
DEBUG:webkit2png:Executing xvfb-run --auto-servernum --server-num 1014690 --server-args=-screen 0, 1024x768x24 ./webkit2png.py --debug --log=arse.log --xvfb=1024 768 http://example.com
This repeating call never ends, and the PNG is never produced.
Whereas if I run the command:
./webkit2png.py --debug --log=arse.log -x 1024 768 http://example.com
then the command that is run is:
DEBUG:webkit2png:Executing xvfb-run --auto-servernum --server-num 1013165 --server-args=-screen 0, 1024x768x24 ./webkit2png.py --debug --log=arse.log http://example.com
DEBUG:webkit2png:Version 20091224, Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3], Qt 4.6.2
DEBUG:webkit2png:loading started
DEBUG:webkit2png:loading finished with result True
DEBUG:webkit2png:Processing result
DEBUG:webkit2png:contentsSize: PyQt4.QtCore.QSize(1020, 700)
And the PNG is produced - and all is well.
Looking at the code (I'm not a pythonist myself) - i suspect some issue around line 443 of the current version:
elif sys.argv[i] in ["-x", "--xvfb"]:
My rationale is that the bare "-x" is followed by a space and the integer:
-x 640 480
whereas the "--xvfb" is followed by an equals sign then immediately the integer:
--xvfb=640 480
So maybe it's not parsing it out as desired.
G
When running the following command
xvfb-run --auto-servernum --server-num=1 /usr/local/bin/webkit2png -t 5 "http://www.weather.com/news/weather/video/more-wintry-precip-for-south" -o test.png -g 1200 1200 -F javascript
Segmentation fault (core dumped)
in /var/log/syslog I get the following error
kernel: [211586.457640] traps: webkit2png[31828] general protection ip:7f6425260787 sp:7fff1e51fb80 error:0 in libQtWebKit.so.4.10.2[7f6423d81000+1fc9000]
Hi!
I know this project is not maintained, but maybe someone would be able to help me.
I've installed webkit2png from AUR, but whe nI run it I get this:
$ webkit2png --help
Traceback (most recent call last):
File "/usr/bin/webkit2png", line 11, in <module>
load_entry_point('webkit2png==0.8.3', 'console_scripts', 'webkit2png')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/site-packages/webkit2png/__init__.py", line 1, in <module>
from webkit2png import WebkitRenderer
File "/usr/lib/python2.7/site-packages/webkit2png/webkit2png.py", line 31, in <module>
from PyQt4.QtWebKit import *
ImportError: No module named QtWebKit
I have qtwebkit installed, and even pyqt4 bindings for Python 2 and Python 3.
Still no go.
Is there any alternative I could use to produce high-resolution PNG images of websites?
Is it somehow possible to define a SSL client certificate (e.g. pfx format) which is necessary to open the URL?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.