chore(deps): replace @postlight/mercury-parser with @postlight/parser (#10862)

This commit is contained in:
Tony
2022-09-23 03:25:56 +08:00
committed by GitHub
parent a0eb4e0c67
commit 30975dd20b
4 changed files with 586 additions and 732 deletions

View File

@@ -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) {