Skip to content

Commit 68c1067

Browse files
author
lucifer
committed
2 parents 2bd0d13 + 6893efd commit 68c1067

File tree

5 files changed

+12848
-7055
lines changed

5 files changed

+12848
-7055
lines changed

‎.github/workflows/main.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the action will run. Triggers the workflow on push or pull request
6+
# events but only for the master branch
7+
on:
8+
push:
9+
branches: [ master ]
10+
pull_request:
11+
branches: [ master ]
12+
13+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14+
jobs:
15+
# This workflow contains a single job called "build"
16+
lint:
17+
# The type of runner that the job will run on
18+
runs-on: ubuntu-latest
19+
20+
# Steps represent a sequence of tasks that will be executed as part of the job
21+
steps:
22+
- name: Super-Linter
23+
uses: github/super-linter@v2.0.0

‎scripts/LeetCodeProvider.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const request = require("request");
21
const Iconv = require("iconv-lite");
32
const cheerio = require("cheerio");
43

@@ -21,8 +20,10 @@ module.exports = LeetCodeProvider = {
2120
.load(sHtml)(QUESTION_DOM_SELECTOR)
2221
.each((idx, ele) => titles.push(ele.attribs["title"]));
2322
Logger.success("获取问题列表成功");
24-
25-
return titles.filter((name) => !name.endsWith(ENGLISH_MARKDOWN_SIGN));
23+
/**
24+
* 由于QUESTION_DOM_SELECTOR 所选择的结构包含非问题标签,获取title会是undefined,在此需将其过滤掉
25+
*/
26+
return titles.filter(Boolean).filter((name) => !name.endsWith(ENGLISH_MARKDOWN_SIGN));
2627
})
2728
.catch((error) => {
2829
Logger.error("获取问题列表失败", error);
@@ -41,3 +42,5 @@ module.exports = LeetCodeProvider = {
4142
});
4243
},
4344
};
45+
46+
LeetCodeProvider.getProblemsTitle()

‎scripts/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
/**
3434
* 抓取页面问题内容的dom元素选择器
3535
*/
36-
QUESTION_DOM_SELECTOR: ".js-navigation-item .content .js-navigation-open",
36+
QUESTION_DOM_SELECTOR: ".position-relative.js-navigation-item .js-navigation-open",
3737

3838
/**
3939
* markdwon下载地址

‎scripts/generateleetcode.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const {
44
SUPPORT_LANGUAGE,
55
DB_JSON_OUTPUT_DIR,
66
RAW_MARKDOWN_OUTPUT_DIR,
7-
ENGLISH_MARKDOWN_SIGN,
8-
} = require("./constants");
7+
} = require('./constants')
8+
9+
10+
911

1012
const genertateLeetcodeToJson = () => {
1113
console.time("genertateLeetcodeToJson");
@@ -46,8 +48,9 @@ const genertateLeetcodeToJson = () => {
4648
});
4749
});
4850
markdown.replace(Utils.getSatelliteDataReg().pre, (noUseMatch, $1) => {
51+
4952
preKnowledge.push({
50-
text: $1,
53+
text: $1.replace('-',''),
5154
link: null,
5255
color: "red",
5356
});

0 commit comments

Comments
 (0)