mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 02:42:57 +08:00
* refactor: add no-implicit-coercion rule for ESLint * fix: errors from deepscan * fix: errors from deepscan * fix: errors from deepscan * fix: errors from deepscan * fix: errors from deepscan * Update docs/en/joinus/quick-start.md Co-authored-by: Sukka <isukkaw@gmail.com> * Update docs/joinus/quick-start.md Co-authored-by: Sukka <isukkaw@gmail.com> * Update lib/routes/av01/tag.js Co-authored-by: Sukka <isukkaw@gmail.com> * Update lib/routes/gov/taiwan/mnd.js Co-authored-by: Sukka <isukkaw@gmail.com> * Update lib/routes/ps/product.js Co-authored-by: Sukka <isukkaw@gmail.com> * refactor: minify html string Co-authored-by: Sukka <isukkaw@gmail.com>
33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const util = require('./utils');
|
|
module.exports = async (ctx) => {
|
|
const user = ctx.params.user;
|
|
const url = 'https://leetcode.com/';
|
|
const response = await got({
|
|
method: 'get',
|
|
url: `${url}${user}`,
|
|
headers: {
|
|
Referer: url,
|
|
},
|
|
});
|
|
const data = response.data;
|
|
const $ = cheerio.load(data);
|
|
const username = $('div.panel-body').find('p').text(); // 用户名
|
|
const img = $('div.panel-body').find('img').attr('src'); // 用户的头像
|
|
const src = `<img src="${img}">`;
|
|
const solvedQuestion = $('ul.list-group').eq(2).children().eq(0).find('span').text(); // 解决的题目
|
|
const acceptedSubmission = $('ul.list-group').eq(2).children().eq(1).find('span').text(); // 通过的提交
|
|
const acceptanceRate = $('ul.list-group').eq(2).children().eq(2).find('span').text(); // 通过率
|
|
const state = ' Most recent submissions';
|
|
const description = 'Solved Question: ' + solvedQuestion + '<br>Accepted Submission: ' + acceptedSubmission + '<br>Acceptance Rate: ' + acceptanceRate + '<br>' + src;
|
|
const list = $('ul.list-group').eq(-1).children().get();
|
|
const result = await util.ProcessFeed(list);
|
|
ctx.state.data = {
|
|
title: username + state,
|
|
link: `https://leetcode.com/${user}`,
|
|
description,
|
|
item: result,
|
|
};
|
|
};
|