Seekable output from ClientForm?

M

Matej Cepl

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?

Thanks a lot,

Matej
 
M

mac

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top