[pyxpcom] Headless Python Browser?
by Don Spaulding other posts by this author
Feb 12 2009 1:09PM messages near this date
view in the new Beta List Site
Re: [pyxpcom] A first Python / XULRunner app - impressions and problems
|
Re: [pyxpcom] Headless Python Browser?
Hello all,
I'm trying to build an entirely headless web browser. At my job we need one
for screenscraping, but I'm sure the utility of a headless browser able to
parse documents *exactly* like a major browser is obvious.
My XPCOM-fu is weak. I'm using the sample layout from the python+xulrunner
tutorial, but I really want to work from the shell, to start totally
chromeless. I run into the following issue trying to navigate to a page. I
assume I'm missing some Vital Initialization Call, but I can't make heads or
tails out of an Exception so devoid of information.
My code:
# sorry if this is butchered by line breaks
FLAGS = 0
from xpcom import components
browser = components.classes['@
mozilla.org/embedding/browser/nsWebBrowser;1'].createInstance()
browser.queryInterface(components.interfaces.nsIWebNavigation)
ios = components.classes["@mozilla.org/network/io-service;1
"].getService(components.interfaces.nsIIOService)
referrer = ios.newURI('http://blah.com/', None, None)
browser.loadURI(u'http://google.com/', FLAGS, referrer,None, None)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/home/don/xulapps/pyxpcom_gui_app/<ipython console> in <module>()
/home/don/xulapps/pyxpcom_gui_app/xulrunner/pylib/xpcom/client/__init__.pyc
in loadURI(self, Param1, Param2, Param3, Param4, Param5)
Exception: -2147418113 (-2147418113)
Does anyone know what I'm doing wrong?
Thanks.
--
Don Spaulding II
Thread:
Don Spaulding
Atul Varma
|