0
import pycurl
from StringIO import StringIO
import gtk
import webkit

wd = gtk.Window()
wd.set_title("example browser")

storage = StringIO()
c=pycurl.Curl()
c.setopt(pycurl.ENCODING,"")
c.setopt(pycurl.FOLLOWLOCATION,1)
c.setopt(pycurl.AUTOREFERER,1)
c.setopt(pycurl.HEADER,1)
c.setopt(pycurl.MAXREDIRS,5)
c.setopt(pycurl.FAILONERROR,1)
c.setopt(pycurl.URL,"http://whatsmyua.com")
c.setopt(pycurl.WRITEFUNCTION, storage.write)
c.perform()
c.close()

html1 = storage.getvalue()
htm = webkit.WebView()

htm.load_string("<p>example page</p><br>" , "text/html" , "utf-8" , html1)

wd.add(htm)
wd.show_all()
gtk.main()

above code downloads the page and then shows a window containing only "example page" string and nothing else. So what should I do . please help......

Wander
  • 1
  • Why use `pycurl`? That's about as easy to use as using a bench-mounted grinding stone to polish your shoes; you are just as likely to get hurt.. – Martijn Pieters Aug 19 '13 at 07:53

1 Answers1

0

You'll want to call it like this:

htm.load_string(html1, 'text/html', 'utf-8', 'file://')

The last parameter is the base URI for relative links in the document.

ptomato
  • 56,175
  • 13
  • 112
  • 165