This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Jython/Python and the fly likes Access html table data in python Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Access html table data in python" Watch "Access html table data in python" New topic
Author

Access html table data in python

radha madaparthy
Greenhorn

Joined: May 08, 2010
Posts: 5
Hello friends,

I know this is a java forum but I have a question on accessing html elements in python script. I am stuck currently trying different options and none seem to work. My problem is described below.

I have a form with table and i have some javascript code to add rows and delete rows on a button click. User enters data and submits the form. At Back end , python script gets invoked and it needs to use the data entered in table for additional processing. I do not know how to do that. I can use Beuatiful Soup but all the examples mentioned are having some hardcoded html and then creating a soup instance..In my case that html has to come from the request.

so beautigul soup does not work for me with my knowledge.

Can someone tell me how can I access the html table data in a python script? Any other ideas are also welcome. Sorry for posting python q here.

my javascript code:

var newRow = document.all("tblGrid").insertRow();


//add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes


var oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='categoryname' size='30'>";


oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='itemid' size='30'>";

oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='itemname' size='30'>";

oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='quantity' size='30'>";


oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='attributes' size='60'> <input type='button' value='Delete' onclick='removeRow(this);'/>";

Thanks,
Radha
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

This is actually a coding site . I've moved your question to our Jython/Python forum where more people know Python.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

Could you build a set of JSON objects for your data rows that you can then submit to your server e.g. using AJAX? That way you don't have to read HTML on the server at all.

Here's an example using Django.


No more Blub for me, thank you, Vicar.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Access html table data in python
 
Similar Threads
dynamically change the width of table cell(td) thorough java script
insertrow calender
add row to table
Multiple Select box Problem
onchange for dynamically added rows