Can CleintForm work with webbrowser?
Diez B. Roggisch
deets at nospam.web.de
Mon Mar 2 02:53:25 EST 2009
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
More information about the Python-list
mailing list