From f00d4457bc52f5c9ff4096b7ad4e55060c024ab3 Mon Sep 17 00:00:00 2001 From: Nick Wynja Date: Wed, 3 Apr 2024 09:28:20 -0400 Subject: [PATCH] feat: adds /parse-html endpoint (#422) --- routes.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/routes.js b/routes.js index 4dc9324..6cd7b20 100755 --- a/routes.js +++ b/routes.js @@ -31,4 +31,19 @@ router.route('/parser').get(async (req, res) => { return res.json(result); }); +router.route('/parse-html').post(async (req, res) => { + let result = { message: 'No URL was provided' }; + + if (req.body.url && req.body.html) { + try { + result = await Mercury.parse(req.body.url, { + html: req.body.html + }); + } catch (error) { + result = { error: true, messages: error.message }; + } + } + return res.json(result); +}); + module.exports = router;