Skip to content

Commit

Permalink
feat: adds /parse-html endpoint (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickwynja authored Apr 3, 2024
1 parent 3eda91e commit f00d445
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f00d445

Please sign in to comment.