fix: 力扣 (#2340)

This commit is contained in:
Nathan
2019-06-08 13:49:48 +08:00
committed by DIYgod
parent d461cf8308
commit 983bb09c57
4 changed files with 16 additions and 47 deletions

View File

@@ -1,12 +1,7 @@
const cheerio = require('cheerio');
const ProcessFeed = async (list, country) => {
let host;
if (country === 'us') {
host = 'https://leetcode.com';
} else {
host = 'https://leetcode-cn.com';
}
const ProcessFeed = async (list) => {
const host = 'https://leetcode.com';
return await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
@@ -19,7 +14,6 @@ const ProcessFeed = async (list, country) => {
.eq(1)
.text();
// 还原相对链接为绝对链接
const pubDate = $('span')
.eq(2)
.text();
@@ -27,23 +21,12 @@ const ProcessFeed = async (list, country) => {
const itemUrl = host + $(bb).attr('href');
let n = 0,
h = 0;
let n1, n2, n3, n4, n5, n6;
if (country === 'us') {
n1 = pubDate.search(/year/);
n2 = pubDate.search(/month/);
n3 = pubDate.search(/week/);
n4 = pubDate.search(/day/);
n5 = pubDate.search(/hour/);
n6 = pubDate.search(/minute/);
} else {
n1 = pubDate.search(/年/);
n2 = pubDate.search(/月/);
n3 = pubDate.search(/周/);
n4 = pubDate.search(/日/);
n5 = pubDate.search(/小时/);
n6 = pubDate.search(/分钟/);
}
const n1 = pubDate.search(/year/);
const n2 = pubDate.search(/month/);
const n3 = pubDate.search(/week/);
const n4 = pubDate.search(/day/);
const n5 = pubDate.search(/hour/);
const n6 = pubDate.search(/minute/);
if (n1 !== -1) {
n = n + parseInt(pubDate[n1 - 2]) * 365;
}
@@ -76,7 +59,6 @@ const ProcessFeed = async (list, country) => {
})
);
};
module.exports = {
ProcessFeed,
};