[pygtk] Gtkmozembed
Jeffrey Barish
jeff_barish at earthlink.net
Thu Sep 3 07:10:13 WST 2009
Does anyone know why this test program works with one string but not the
other? Using the load_url method works in both cases.
import urllib2
import gtk
import gtkmozembed
USER_AGENT = "Mozilla/5.0 (compatible; Konqueror/4.2; Linux; X11; x86_64)
KHTML/4.2.4 (like Gecko) Fedora/4.2.4-2.fc11"
class MozembedTest(object):
def __init__(self):
window = gtk.Window()
window.set_size_request(900, 500)
window.connect("destroy", gtk.main_quit)
mozembed = gtkmozembed.MozEmbed()
window.add(mozembed)
window.show_all()
WIKI_URL = "http://en.wikipedia.org/wiki/Special:Search/"
string = "B.B. King" # this string works
#string = "Deuces Wild" # this string does not work
url = WIKI_URL + urllib2.quote(string.encode("utf-8"))
if False:
mozembed.load_url(url) # both strings work
else:
fd = urllib2.urlopen(urllib2.Request(url, headers={'User-Agent':
USER_AGENT}))
html = fd.read()
fd.close()
mozembed.open_stream(url, "text/html")
mozembed.append_data(html, len(html))
mozembed.close_stream()
def run(self):
gtk.main()
app = MozembedTest()
app.run()
--
Jeffrey Barish
More information about the pygtk
mailing list