File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access html table data in python

 
radha madaparthy
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is actually a coding site . I've moved your question to our Jython/Python forum where more people know Python.
 
chris webster
Bartender
Pie
Posts: 2369
31
Linux Oracle Postgres Database Python Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic