2022-01-08 17:05:05 +00:00
|
|
|
const https = require('https');
|
|
|
|
const turndown = require('turndown');
|
|
|
|
const { Readability } = require('@mozilla/readability');
|
|
|
|
const JSDOM = require('jsdom').JSDOM;
|
|
|
|
|
|
|
|
service = new turndown();
|
|
|
|
|
|
|
|
const express = require('express')
|
|
|
|
const app = express()
|
2022-01-08 17:28:18 +00:00
|
|
|
const port = process.env.PORT
|
2022-01-08 17:05:05 +00:00
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
|
|
|
url = req.query.url;
|
|
|
|
read_url(url, res);
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
})
|
|
|
|
|
|
|
|
function read_url(url, res) {
|
|
|
|
JSDOM.fromURL(url).then((document)=>{
|
|
|
|
let reader = new Readability(document.window.document);
|
|
|
|
let article = reader.parse();
|
|
|
|
let result = service.turndown(article.content);
|
|
|
|
res.send(result);
|
|
|
|
});
|
|
|
|
}
|