UNPKG

article-parser

Version:

To extract main article from given URL

39 lines (34 loc) 697 B
import express from 'express' import { extract } from 'article-parser' const app = express() const meta = { service: 'article-parser', lang: 'typescript', server: 'express', platform: 'node' } app.get('/', async (req, res) => { const url = req.query.url if (!url) { return res.json(meta) } try { const data = await extract(url) return res.json({ error: 0, message: 'article has been extracted successfully', data, meta }) } catch (err) { return res.json({ error: 1, message: err.message, data: null, meta }) } }) app.listen(3100, () => { console.log('Server is running at http://localhost:3100') })