mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
chore(deps): replace @postlight/mercury-parser with @postlight/parser (#10862)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const entities = require('entities');
|
||||
const cheerio = require('cheerio');
|
||||
const { simplecc } = require('simplecc-wasm');
|
||||
// const got = require('@/utils/got');
|
||||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
const RE2 = require('re2');
|
||||
|
||||
@@ -252,17 +252,12 @@ module.exports = async (ctx, next) => {
|
||||
const parsed_result = await ctx.cache.tryGet(`mercury-cache-${link}`, async () => {
|
||||
// if parser failed, return default description and not report error
|
||||
try {
|
||||
mercury_parser = mercury_parser || require('@postlight/mercury-parser');
|
||||
mercury_parser = mercury_parser || require('@postlight/parser');
|
||||
|
||||
// const res = await got(link);
|
||||
// const $ = cheerio.load(res.data, {
|
||||
// xmlMode: true,
|
||||
// });
|
||||
const { data: res } = await got(link);
|
||||
const $ = cheerio.load(res);
|
||||
const result = await mercury_parser.parse(link, {
|
||||
// html: $.html(),
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
html: $.html(),
|
||||
});
|
||||
return result;
|
||||
} catch (e) {
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
"remark-parse": "9.0.0",
|
||||
"remark-preset-prettier": "0.5.1",
|
||||
"remark-stringify": "9.0.1",
|
||||
"request-promise-native": "1.0.9",
|
||||
"staged-git-files": "1.3.0",
|
||||
"string-width": "4.2.3",
|
||||
"supertest": "6.2.4",
|
||||
@@ -81,7 +82,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@koa/router": "12.0.0",
|
||||
"@postlight/mercury-parser": "2.2.1",
|
||||
"@postlight/parser": "2.2.2",
|
||||
"@sentry/node": "7.13.0",
|
||||
"aes-js": "3.1.2",
|
||||
"art-template": "4.13.2",
|
||||
|
||||
@@ -313,12 +313,12 @@ describe('wrong_path', () => {
|
||||
});
|
||||
|
||||
describe('fulltext_mode', () => {
|
||||
it.skip(`fulltext`, async () => {
|
||||
it(`fulltext`, async () => {
|
||||
const response = await request.get('/test/1?mode=fulltext');
|
||||
expect(response.status).toBe(200);
|
||||
const parsed = await parser.parseString(response.text);
|
||||
expect(parsed.items[0].content).not.toBe(undefined);
|
||||
}, 10000);
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
describe('complicated_description', () => {
|
||||
|
||||
Reference in New Issue
Block a user