How to parse form in client side?

M

Muddy Coder

Hi Folks,

cgi module can easily acquire the all fields of data input from client
side, through a form. Then, a simple line of code:

form_dict = cgi.FieldStorage()

grabs all data into a dictionary form_dict. The rest becomes a piece
of cake by querying the form_dict. Nice!

However, it is done in the server side. Now I want to do the same in
the client side. first of all, I get the source code of a HTML form by
using urllib, from server, with code below:

html_source = urllib.urlopen(URL).read()

Then, I need to parse this html_source file, at client side. Is there
a module to handle this? Can somebody help? Thanks!


Muddy Coder
 
C

Chris Rebert

Hi Folks,

cgi module can easily acquire the all fields of data input from client
side, through a form. Then, a simple line of code:

form_dict = cgi.FieldStorage()

grabs all data into a dictionary form_dict. The rest becomes a piece
of cake by querying the form_dict. Nice!

However, it is done in the server side. Now I want to do the same in
the client side. first of all, I get the source code of a HTML form by
using urllib, from server, with code below:

html_source = urllib.urlopen(URL).read()

Then, I need to parse this html_source file, at client side. Is there
a module to handle this? Can somebody help? Thanks!

http://wwwsearch.sourceforge.net/ClientForm/

Cheers,
Chris
 
S

Stefan Behnel

Muddy said:
cgi module can easily acquire the all fields of data input from client
side, through a form. Then, a simple line of code:

form_dict = cgi.FieldStorage()

grabs all data into a dictionary form_dict. The rest becomes a piece
of cake by querying the form_dict. Nice!

However, it is done in the server side. Now I want to do the same in
the client side. first of all, I get the source code of a HTML form by
using urllib, from server, with code below:

html_source = urllib.urlopen(URL).read()

Then, I need to parse this html_source file, at client side. Is there
a module to handle this? Can somebody help? Thanks!

lxml.html has good form handling support:

http://codespeak.net/lxml/lxmlhtml.html#forms

Stefan
 

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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top