parser icon indicating copy to clipboard operation
parser copied to clipboard

Feature request: JSON output

Open matthewpwatkins opened this issue 6 years ago • 0 comments

Similar to #316, I would love to be able to specify a different output mode. In this case, JSON instead of HTML. Example usage:

Mercury.parse({ url: myURL, outputMode: 'json' }).then(result => console.log(result));

or

Mercury.parse({myURL, 'json').then(result => console.log(result));

Example result:

{
  "title": "Every developer should write a personal automation API",
  "content": [
    { "type": "header1", "value": "Why I love it" },
    { "type": "paragraph", "value": "A few years ago I fell in love..."},
    { "type": "image", "src": "https://..." },
    { "type": "unordered-list", "value": [
      { "type": "list-item", "value": "list item one" }
    ]}
  ],
  "author": "Wikipedia Contributors",
  "date_published": "2016-09-16T20:56:00.000Z",
  "lead_image_url": null,
  "dek": null,
  "next_page_url": null,
  "url": "https://www.anotherdevblog.net/posts/every-developer-should-write-a-personal-automation-api",
  "domain": "www.anotherdevblog.net",
  "excerpt": "Every developer should write a personal automation API",
  "word_count": 4677,
  "direction": "ltr",
  "total_pages": 1,
  "rendered_pages": 1
}

matthewpwatkins avatar Mar 08 '19 13:03 matthewpwatkins