Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added option for treating URL as url-encoded

It fixes errors with non-ascii url-encoded URls
  • Loading branch information...
commit 11c28dd27361d4a108aaf0d2a76faa252bfdf9c8 1 parent 614c2fb
@ventura ventura authored
Showing with 8 additions and 4 deletions.
  1. +3 −0  scripts/webkit2png
  2. +5 −4 webkit2png/webkit2png.py
View
3  scripts/webkit2png
@@ -113,6 +113,8 @@ if __name__ == '__main__':
help="Render output on a transparent background (Be sure to have a transparent background defined in the html)", default=False)
parser.add_option("", "--style", dest="style",
help="Change the Qt look and feel to STYLE (e.G. 'windows').", metavar="STYLE")
+ parser.add_option("", "--encoded-url", dest="encoded_url", action="store_true",
+ help="Treat URL as url-encoded", metavar="ENCODED_URL", default=False)
parser.add_option("-d", "--display", dest="display",
help="Connect to X server at DISPLAY.", metavar="DISPLAY")
parser.add_option("--debug", action="store_true", dest="debug",
@@ -181,6 +183,7 @@ if __name__ == '__main__':
renderer.format = options.format
renderer.grabWholeWindow = options.window
renderer.renderTransparentBackground = options.transparent
+ renderer.encodedUrl = options.encoded_url
if options.scale:
renderer.scaleRatio = options.ratio
View
9 webkit2png/webkit2png.py
@@ -114,6 +114,7 @@ def __init__(self,**kwargs):
self.ignoreConfirm = kwargs.get('ignoreConfirm', True)
self.ignorePrompt = kwargs.get('ignorePrompt', True)
self.interruptJavaScript = kwargs.get('interruptJavaScript', True)
+ self.encodedUrl = kwargs.get('encodedUrl', False)
# Set some default options for QWebPage
self.qWebSettings = {
@@ -264,10 +265,10 @@ def _load_page(self, url, width, height, timeout):
cancelAt = time.time() + timeout
self.__loading = True
self.__loadingResult = False # Default
- # TODO: fromEncoded() needs to be used in some situations. Some
- # sort of flag should be passed in to WebkitRenderer maybe?
- #self._page.mainFrame().load(QUrl.fromEncoded(url))
- self._page.mainFrame().load(QUrl(url))
+ if self.encodedUrl:
+ self._page.mainFrame().load(QUrl.fromEncoded(url))
+ else:
+ self._page.mainFrame().load(QUrl(url))
while self.__loading:
if timeout > 0 and time.time() >= cancelAt:
raise RuntimeError("Request timed out on %s" % url)
Please sign in to comment.
Something went wrong with that request. Please try again.