[python-win32] Re: Python-win32 Digest, Vol 53, Issue 3

Roger Upole rwupole at msn.com
Sat Aug 4 01:09:48 CEST 2007


Huang Guan wrote:
> Thanks for your comments, according the code suggestion you gave:
>         ie.Navigate('about:blank')
> p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit)
>    p.Load(<PyIStream that contains content>),
> confirm Load() metchod in existence.
>
> Could you give some examples on how to use PyISteream for my
> reference? It's very difficult to find use paradigm in pywin32.chm.
>
> 1.) How can we use p.Save(<PyIStream that contains con tent>) method,
> save html source and html header into a string variant?
> 2.) same as part 1,how to use a string variant £¨string=html
> source£©,load into ie.Document control?
> 3) If execute p.Save (), and p.Load () successfully, as initialize
> ie.Document control with ie.Navigate ( 'about : blank') before, will
> the IE original URL address bar become "about : blank"? I want to keep
> the original IE address bar URL unchanged. Is it possible?


There are a couple of IStream implementations included in the Pywin32
distribution.  Take a look at win32com.server.util.FileStream for file
operations, and \win32com\test\testStreams.py for a string based
approach.

Here's an example of creating an IStream suitable for loading content from a file:
import pythoncom
from win32com.server import util
f=open('somepage.html','r')
fs=util.FileStream(f)
istream=util.wrap(fs, pythoncom.IID_IStream)

If you already have a document loaded, you can omit the Navigate
part, and the URL remains as it was.

        Roger



More information about the python-win32 mailing list