python webkit with proxy support
Question: I am writing a python script for scraping a webpage. I have created a webkit
webview object and used the open method for loading the url. But I want to
load the url through a proxy. How can i done this ? How to integrate webkit
with proxy? which webkit class support proxy?


Answer: try below code snippets. (reference from
[url](http://code.google.com/p/pywebkitgtk/issues/detail?id=53))

    
    
    import gtk, webkit
    import ctypes
    libgobject = ctypes.CDLL('/usr/lib/libgobject-2.0.so.0')
    libwebkit = ctypes.CDLL('/usr/lib/libsoup-2.4.so.1')
    libsoup = ctypes.CDLL('/usr/lib/libsoup-2.4.so.1')
    libwebkit = ctypes.CDLL('/usr/lib/libwebkit-1.0.so')
    
    proxy_uri = libsoup.soup_uri_new('http://127.0.0.1:8000') # set your proxy url
    
    session = libwebkit.webkit_get_default_session()
    libgobject.g_object_set(session, "proxy-uri", proxy_uri, None)
    
    w = gtk.Window()
    s = gtk.ScrolledWindow()
    v = webkit.WebView()
    s.add(v)
    w.add(s)
    w.show_all()
    
    v.open('http://www.google.com')
    

Hope, it could help you.

