Can CleintForm work with webbrowser?

M

Muddy Coder

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
 
C

Chris Rebert

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
 
D

Diez B. Roggisch

Muddy said:
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
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top