Opening A Website Frame Or Image In Python
So i am fairly fluent with python and have used urllib2 and Cookies a lot for website automation. I just stumbled upon the 'webbrowser' module which can open a url in your default
Solution 1:
It's not possible with the webbrowser module. All webbrowser does is provide a simple way to identify the default web browser and feed a URL to it.
If you want to render just a portion of a page, you need something that can either take arbitrary HTML fragments or can inject some Javascript after loading a page to strip out the unwanted elements.
For that, what you need is to build a purpose-specific web browser that's nothing more than a dialog box containing a web widget.
That can be done using any of the following combinations of libraries:
- PyQt and the included QtWebKit (GPL or Commercial, Windows/Mac/Linux)
- PySide and the included QtWebKit (LGPL, Linux)
- PyGTK and PyWebKitGTK (LGPL, Easy on Linux... no clue about Windows or OSX)
- PyGTK and GTKMozEmbed (LGPL, Easy on Linux... no clue about Windows or OSX)
- wxPython and the included wxIEHtmlWindow (BSD-like, Windows-only. Embeds Internet Explorer.)
- wxPython and the included wxWebKitCtrl (BSD-like, OSX-only)
- wxPython and wxWebKit (BSD-like, Windows/Mac/Linux)
My advice:
- If GPL licensing is OK, use PyQt.
- If GPL licensing isn't OK:
- For Linux, use PySide or PyGTK with PyWebKitGTK (GTKMozEmbed is heavy)
- For Windows, use wxPython with wxIEHtmlWindow
- For OSX, you'll have to ask someone else.
Post a Comment for "Opening A Website Frame Or Image In Python"