Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Can CleintForm work with webbrowser?

Reply
Thread Tools

Can CleintForm work with webbrowser?

 
 
Muddy Coder
Guest
Posts: n/a
 
      03-02-2009
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
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      03-02-2009
On Sun, Mar 1, 2009 at 9:36 PM, Muddy Coder <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      03-02-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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Can anyone tell me if pygame and Tkinter can work together? Nathan Pinno Python 5 11-19-2005 12:18 AM
Can anyone tell me if pygame and Tkinter can work together? Nathan Pinno Python 1 11-16-2005 01:28 AM
i still can not get asp or asp.net to work on xp sp2 can some help with step by step craig dicker ASP .Net 1 07-10-2005 10:48 AM
Hi I am new to asp i can not get it to work on xp pro sp2 even though the localhost work but asp pages dont so can some one help craig dicker ASP .Net 9 07-07-2005 11:52 AM
Mechanize: Can't get it to work. Can I help make it work next week? Xeno Campanoli Ruby 1 07-01-2005 10:32 PM



Advertisments