Can CleintForm work with webbrowser?

Discussion in 'Python' started by Muddy Coder, Mar 2, 2009.

  1. Muddy Coder

    Muddy Coder Guest

    Hi Folks,

    ClientForm is cool at grabbing and parsing stuff from server, I like
    it. After the stuff parsed, and even filled values for the Controls, I
    popped up an idea of displaying what I had done with webbrowser. Look
    at the code:

    import ClientForm
    import urllib2
    import webbrowser

    request = urllib2.Request(url)
    response = urllib2.urlopen(request)
    forms = ClientForm.ParseResponse(response, backwards_compat=False)
    ....parsing and filling forms

    # now I want to display the forms I modified, with webbrowser
    webbrowser.open_new_tab (???)

    ??? is supposed to be a url. But this moment I want to display the
    form I filled. Obviously webbrowser takes url as argument rather than
    a form. Is there other options to do this? Somebody can help? Thanks!


    Muddy Coder
    Muddy Coder, Mar 2, 2009
    #1
    1. Advertising

  2. Muddy Coder

    Chris Rebert Guest

    On Sun, Mar 1, 2009 at 9:36 PM, Muddy Coder <> wrote:
    > Hi Folks,
    >
    > ClientForm is cool at grabbing and parsing stuff from server, I like
    > it. After the stuff parsed, and even filled values for the Controls, I
    > popped up an idea of displaying what I had done with webbrowser. Look
    > at the code:
    >
    > import ClientForm
    > import urllib2
    > import webbrowser
    >
    > request = urllib2.Request(url)
    > response = urllib2.urlopen(request)
    > forms = ClientForm.ParseResponse(response, backwards_compat=False)
    > ...parsing and filling forms
    >
    > # now I want to display the forms I modified, with webbrowser
    > webbrowser.open_new_tab (???)
    >
    > ??? is supposed to be a url. But this moment I want to display the
    > form I filled. Obviously webbrowser takes url as argument rather than
    > a form.  Is there other options to do this? Somebody can help? Thanks!


    You could run a local HTTP server in another Python process/thread
    using SimpleHTTPServer
    (http://docs.python.org/library/simplehttpserver.html) and have it
    serve the modified webpage you produce. Then you could call webbrowser
    with a localhost address corresponding to the HTTP server you're
    running.

    Cheers,
    Chris

    --
    Shameless self-promotion:
    http://blog.rebertia.com
    Chris Rebert, Mar 2, 2009
    #2
    1. Advertising

  3. Muddy Coder schrieb:
    > Hi Folks,
    >
    > ClientForm is cool at grabbing and parsing stuff from server, I like
    > it. After the stuff parsed, and even filled values for the Controls, I
    > popped up an idea of displaying what I had done with webbrowser. Look
    > at the code:
    >
    > import ClientForm
    > import urllib2
    > import webbrowser
    >
    > request = urllib2.Request(url)
    > response = urllib2.urlopen(request)
    > forms = ClientForm.ParseResponse(response, backwards_compat=False)
    > ...parsing and filling forms
    >
    > # now I want to display the forms I modified, with webbrowser
    > webbrowser.open_new_tab (???)
    >
    > ??? is supposed to be a url. But this moment I want to display the
    > form I filled. Obviously webbrowser takes url as argument rather than
    > a form. Is there other options to do this? Somebody can help? Thanks!


    I don't think that ClientForm supports this out of the box, as "filling
    out a form" probably means something very different in terms of internal
    representation for a browser and ClientForm. But *if* you can get it to
    spit out the HTML, you can open the browser and point it to a file copy
    of your html.

    But you'd need to rewrite all resource links first, to point absolutly
    to the host the page came from.

    All in all I don't think this is the road to success. If you really want
    something like this, learn how to code an extension to firefox that does
    this. Or use e.g. selenium + selenium server to remote control firefox
    through python.

    Diez
    Diez B. Roggisch, Mar 2, 2009
    #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. Daniel Frede

    ASPNET and Webbrowser control

    Daniel Frede, May 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,567
    Ken Cox [Microsoft MVP]
    May 18, 2004
  2. ASP .NET Newbie
    Replies:
    10
    Views:
    14,721
    jojobouy
    Sep 28, 2007
  3. Muddy Coder

    Can webbrowser module get source code?

    Muddy Coder, Jan 24, 2009, in forum: Python
    Replies:
    1
    Views:
    700
    Benjamin Peterson
    Jan 25, 2009
  4. Aiver

    Can other C# contrl display HTML without WebBrowser?

    Aiver, Mar 13, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    402
    Peter Bucher [MVP]
    Mar 13, 2008
  5. Xeno Campanoli
    Replies:
    1
    Views:
    338
    James Britt
    Jul 1, 2005
Loading...

Share This Page