Reputation: 23
I am having trouble recreating the structure of a table after scraping data from another website. I am using the example found in this fiddle: http://jsfiddle.net/skelly/m4QCt/
An example of what I am trying to recreate is here: http://jsfiddle.net/curly33/v5h6G/
$.each($foop.find('table.data tr'), function(idx, item) {
mytext = $(item).children().remove().text();
$('<td>'+mytext+'</td>').appendTo($('#divs tr'));
});
The roster table is a perfect example of what I am trying to recreate. I just cannot think of a way to separate the data into individual td cells on separate table row lines instead of bunching all of the scraped data from each row into td cells.
Upvotes: 0
Views: 189
Reputation: 562
Why don't you just loop through the cells of the scrapped tr? It will be something like:
$.each($foop.find('table.data tr'), function(idx, item) {
var tr = $("<tr><td>a</td></tr>");
$.each($(item).children(), function(index, cell) {
tr.append('<td>' + $(cell).html() + '</td>');
});
tr.appendTo($('#divs'));
});
See http://jsfiddle.net/v5h6G/1/
Upvotes: 2