Pygtk WebKit get source html

python webkit
webkit js
webkit source code
webkitgtk windows
python html gui
webkit download
how to make a browser in python

Here is my sample code. How do I get the html source code of the current page. It only prints 'GString at 0x8875130' . How to convert it to real text contains html?

from gi.repository import WebKit
from gi.repository import Gtk, Gdk

def get_source(webobj, frame):
    print "loading..."
    x = web.get_main_frame().get_data_source().get_data()
    print x

win = Gtk.Window()

web = WebKit.WebView()"")
web.connect("load-finished", get_source)




print x.str

Data is available as .str member of GLib.String object. For further details try help(GLib.String) on python prompt after importing libraries.

python - Pygtk WebKit get source html, print x.str. Data is available as .str member of GLib.String object. For further details try help(GLib.String) on python prompt after importing  PyWebkitGtk comes with a demo application which is practically a fully-featured web browser in its own right. PyWebkitGtk is the basis for PyjamasDesktop , which provides a much easier-to-use framework for application development than PyWebkitGtk on its own (it is fair to say that whilst PyWebkitGtk is on the same level as PyGtk2 , PyjamasDesktop is on the same level as KiWi ).

#Before you can use the require_version() method from gi, you need to import the gi module.
import gi

#Specify versions to import from the repository.

#Import the modules that will give us a Graphical User Interface (GUI) and a WebKit Browser.
from gi.repository import Gtk,WebKit

#Define your function to handle the WebKit's "load-finished" event.  The webobj is a reference to the WebKit that triggered the event.  The frame is which frame triggered the event (useful if the loaded page has multiple frames like a frameset.
def ShowSource(webobj,frame):
    #What you have printed is what results from this line.  This line returns a reference to an object, so when you print it's return value, a description is all Python knows to print.

    #You can get the text the object is carrying from it's "str" member property like I do below.

    #Send the source code string text to the output stream.

#Create Window object.

#Set the text to display in the window's caption.
Window.set_title("Test of Python GTK and WebKit")

#Set the starting window size in pixels.

#Create the WebView object.

#Tell the WebView object to load a website."")

#Set the event handler for the WebView's "load-finished" event to the function we have above.

#Add the WebView to the window.

#Set the handler of the window closing to cause GTK to exit.  Without this, GTK will hang when it quits, because it's main loop that we start later will still be running.  Gtk.main_quit will stop the main loop for GTK.

#Display the window.

#Start GTK's main loop.

Python Webkit DOM Bindings, Python Webkit DOM Bindings, making Python a peer of javascript. How do I get Python-Webkit? The Python Webkit DOM For more explanation, see http://www​ This project is meant  To modify any of the web_view settings, you can either create a new WebKitSettings object with webkit_settings_new (), setting the desired preferences, and then replace the existing web_view settings with webkit_web_view_set_settings () or get the existing web_view settings and update it directly.

This way works for me.

#!/usr/bin/env python
import webkit, gtk

def get_source(webobj, frame):
    print "loading..."
    x = web.get_main_frame().get_data_source().get_data()
    print x

win = gtk.Window()
win.connect('destroy', lambda w: gtk.main_quit())
vbox = gtk.VBox(spacing=5)
web = webkit.WebView()
vbox.pack_start(web, fill=True, expand=True)

web = webkit.WebView()"")
web.connect("load-finished", get_source)

browser_settings = web.get_settings()
browser_settings.set_property('user-agent', 'Mozilla/5.0 (X11; Linux i586; rv:31.0) Gecko/20100101 Firefox/31.0')
browser_settings.set_property('enable-default-context-menu', True)
browser_settings.set_property('enable-accelerated-compositing', True)
browser_settings.set_property('enable-file-access-from-file-uris', True)


The WebKitGTK Project, WebKitGTK is a full-featured port of the WebKit rendering engine, suitable for of web integration, from hybrid HTML/CSS applications to full-fledged web browsers​. WebKitGTK also uses process separation to seamlessly support GTK 2 File a bug; ‣ Get the code; ‣ How to build; ‣ How to submit code; ‣ Stable branch. PyGTK allows you to write full featured GTK programs in Python. It is targetted at GTK 2.x, and can be used in conjunction with gnome-python to write Gnome applications.

The main frame document title of this #WebKitWebView. If the title , Get the presentation type of WebKitWebView when created for automation. The mime type of the document will be "text/html". You can It receives an URI as argument, that is used as the image source. Generated by GTK-Doc V1.32.1. To download a pre-built bundle containing the latest WebKit, visit WebKit Build Archives. To browse the source code online, visit WebKit Trac. To work with the WebKit source tree, you will need a Subversion or a Git client installed. See Installing Developer Tools for information on how to install Subversion.

Python Web Scraping, Executing JavaScript To confirm your WebKit installation can execute Here is the source code: <html> <body><div id="result"></div> <script>document. It offers WebKit’s full functionality and is useful in a wide range of systems from desktop computers to embedded systems like phones, tablets, and televisions. WebKitGTK is made by a lively community of developers and designers, who hope to bring the web platform to everyone.

wxWebView Class Reference, Under GTK the WebKit backend uses WebKitGTK+. The current minimum version Get the HTML source code of the currently displayed document. More. Update August 12, 2010 - Update missing files: iconv and libhunspell, thanks to J. Seipp - Adding locales - Been trying webkit-1.2.3 with webM support but unable to get ffmpeg working