Seekable output from ClientForm?

Discussion in 'Python' started by Matej Cepl, Feb 9, 2005.

  1. Matej Cepl

    Matej Cepl Guest

    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
     
    Matej Cepl, Feb 9, 2005
    #1
    1. Advertising

  2. Matej Cepl

    mac Guest

    In article <>, 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
     
    mac, Feb 9, 2005
    #2
    1. Advertising

  3. Matej Cepl

    Guest

    Thanks a lot!

    Matej
     
    , Feb 10, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Johnson
    Replies:
    0
    Views:
    2,801
    Joe Johnson
    Apr 2, 2005
  2. narke

    A ClientForm Question

    narke, Apr 1, 2005, in forum: Python
    Replies:
    5
    Views:
    543
    John J. Lee
    Apr 6, 2005
  3. kostem

    ClientForm question

    kostem, May 23, 2005, in forum: Python
    Replies:
    0
    Views:
    287
    kostem
    May 23, 2005
  4. m0sf3t

    A Clientform question

    m0sf3t, May 24, 2005, in forum: Python
    Replies:
    0
    Views:
    335
    m0sf3t
    May 24, 2005
  5. John J Lee
    Replies:
    4
    Views:
    392
    John J. Lee
    Mar 23, 2006
Loading...

Share This Page