fergiemcdowall / norch-document-processor

A library for parsing HTML into any sort of JSON you want
MIT License
9 stars 4 forks source link

A small documentation-issue on howto write an adapter #2

Open eklem opened 10 years ago

eklem commented 10 years ago

Mostly I guess this is a result of lacking JavaScript/jQuery-knowledge from my side, but I'll put my findings in the Wiki, so please help me out.

I got a page with a UL-list, and the result from the adapter is just the content of the last LI-tag: "melis" Actual page: http://www.flickr.com/photos/eklem/11321534604/ Firepath-debugging: http://www.flickr.com/photos/eklem/11321534604/

The adapter-jQuery:

  $(".ingredients .ingredientWrapper").each(function(i, e) {
    var ingredients = $(e);
    doc['ingredients'] = ingredients.text();
  });

So I understand that it's overwritten each time "each" runs, but how to get a nice ingredients-json-list with several singular "ingredient"?

eklem commented 10 years ago

Seems I found the answer in Cheerio's documentation: https://github.com/cheeriojs/cheerio#each-functionindex-element-

I'll test later and update the wiki if it works.