Seekable output from ClientForm?

mac mac at ceti.pl
Wed Feb 9 17:32:55 EST 2005


In article <35993bcb.0502091338.34591a7 at posting.google.com>, Matej Cepl wrote:
> Hi,
> 
> using python 2.3, ClientForm, and ClientCookie and I have this code:
> 
> opener = ClientCookie.build_opener(ClientCookie.HTTPRefererProcessor,
>                                    ClientCookie.HTTPRefreshProcessor,
>                                    ClientCookie.SeekableProcessor)
> 
> response = opener.open(lxURL)
> forms = ClientForm.ParseResponse(response)
> form = forms[0]
> response.seek(0)
> 
> form['extpatid'] = MyNEUlogin
> form['extpatpw'] = MyNEUpassword
> formopener = form.click()
> 
> response2 = ClientCookie.urlopen(formopener)
>
> guidednews = re.compile("s_guidednews.html")
> 
> response2.seek(0)
> h = htmllib.HTMLParser(formatter.NullFormatter())
> h.feed(response2.read())
> print h.anchorlist
> 
> Unfortunately, it doesn't work, because response2 was created by
> ClientForm and it is not seekable (apparently, I get "AttributeError:
> addinfourl instance has no attribute 'seek'").
> 
> How to make output of ClientForm seekable, please?

Instead of:
  response2 = ClientCookie.urlopen(formopener)
try:
  opener.open(formopener)

Cheers, 
Maciek




More information about the Python-list mailing list