[XML-SIG] Persistence of HTMLDocument
sskau
sskau@pchome.com.tw
Tue, 24 Apr 2001 08:51:03 +0800
Dear All:
I used the PyXML 0.6.5 to parse some html files and then
try to save this html document object to disk (using shelve). (The
reason is that we
could speed up the loading process without further parsing)
I got the following exception:
Traceback (innermost last):
File "docper.py", line 18, in ?
newdoc=3Ddocobj["doc"]
File "e:\Python\Lib\shelve.py", line 65, in __getitem__
return Unpickler(f).load()
TypeError: ('too many arguments; expected 1, got 2', <class xml.dom.html.HT=
MLDo
ument.HTMLDocument at 988cb0>, (None,))
The Source code is:
=66rom xml.dom.ext.reader import HtmlLib
=66rom xml.dom import ext
import shelve
stream =3D open("c:\\temp\\new.html")
doc=3DHtmlLib.Reader().fromStream(stream)
# persistence of HtmlDocument
docobj =3D shelve.open("c:\\temp\\doc.obj")
docobj["doc"]=3Ddoc
docobj.close()
stream.close()
# reopen, load persistence document
docobj =3D shelve.open("c:\\temp\\doc.obj")
newdoc=3Ddocobj["doc"]
ext.PrettyPrint(newdoc)
Have anyone concern the persistence of paresed HtmlDocument DOM tree ?
Thanks a lot
Shi-Shiuan Kao
==========================================================
PC home 免費電子信箱,申請請至: http://www.pchome.com.tw
PC home Online 網路家庭 會員第一,台灣最大的入口網站
==========================================================