Skip to content

Commit bcf114c

Browse files
authored
Merge pull request #3066 from Liu233w/fix-snapshot
fix(crawler): fix leetcode_cn
2 parents cc38179 + 9ba2b27 commit bcf114c

19 files changed

+65
-26
lines changed

crawler/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ crawlers:
8484
meta:
8585
title: LeetCode_CN
8686
description:
87-
url: https://leetcode-cn.com
87+
url: https://leetcode.cn
8888
csu:
8989
meta:
9090
title: CSU

crawler/crawlers/leetcode_cn.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,40 @@ module.exports = async function (config, username) {
77
}
88

99
const input = {
10-
query: 'query userPublicProfile($userSlug:String!){userProfilePublicProfile(userSlug:$userSlug){submissionProgress{totalSubmissions acTotal}}}',
10+
query: `
11+
query userSessionProgress($userSlug:String!){
12+
userProfileUserQuestionSubmitStats(userSlug:$userSlug){
13+
acSubmissionNum {
14+
difficulty
15+
count
16+
}
17+
totalSubmissionNum {
18+
difficulty
19+
count
20+
}
21+
}
22+
}`,
1123
variables: { userSlug: username },
1224
}
1325

1426
const res = await request
15-
.post('https://leetcode-cn.com/graphql')
27+
.post('https://leetcode.cn/graphql/')
28+
.set('User-Agent', 'ojhunt/1.0.0')
1629
.send(input)
1730

18-
const data = res.body.data.userProfilePublicProfile
31+
const data = res.body.data.userProfileUserQuestionSubmitStats
32+
const acList = data.acSubmissionNum
33+
const subList = data.totalSubmissionNum
1934

20-
if (!data) {
35+
if (acList.length === 0 && subList.length === 0) {
2136
throw new Error('The user does not exist')
2237
}
2338

39+
const solved = acList.map(item => item.count).reduce((a, b) => a + b)
40+
const submissions = subList.map(item => item.count).reduce((a, b) => a + b)
41+
2442
return {
25-
solved: data.submissionProgress.acTotal,
26-
submissions: data.submissionProgress.totalSubmissions,
43+
solved,
44+
submissions,
2745
}
2846
}

e2e/__test__/pages/__snapshots__/pages_snapshot.test.js.snap

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`/ 1`] = `
77
<head>
88
<meta data-n-head="ssr" charset="utf-8">
99
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
10-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
10+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
1111
<title>OJ Analyzer</title>
1212
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
1313
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -952,7 +952,7 @@ exports[`/about 1`] = `
952952
<head>
953953
<meta data-n-head="ssr" charset="utf-8">
954954
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
955-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
955+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
956956
<title>About - OJ Analyzer</title>
957957
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
958958
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -1889,7 +1889,7 @@ exports[`/history 1`] = `
18891889
<head>
18901890
<meta data-n-head="ssr" charset="utf-8">
18911891
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
1892-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
1892+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
18931893
<title>History - OJ Analyzer</title>
18941894
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
18951895
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -3216,7 +3216,7 @@ exports[`/history/{historyId} 1`] = `
32163216
<head>
32173217
<meta data-n-head="ssr" charset="utf-8">
32183218
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
3219-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
3219+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
32203220
<title>History - OJ Analyzer</title>
32213221
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
32223222
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -4429,7 +4429,7 @@ exports[`/history/{historyId} 1`] = `
44294429
leetcode_cn: {
44304430
title: "LeetCode_CN",
44314431
description: a,
4432-
url: "https:\\u002F\\u002Fleetcode-cn.com"
4432+
url: "https:\\u002F\\u002Fleetcode.cn"
44334433
},
44344434
csu: {
44354435
title: "CSU",
@@ -4506,6 +4506,11 @@ exports[`/history/{historyId} 1`] = `
45064506
description: a,
45074507
url: "https:\\u002F\\u002Fdmoj.ca\\u002F"
45084508
},
4509+
sdutoj: {
4510+
title: "SDUT OJ",
4511+
description: a,
4512+
url: "https:\\u002F\\u002Foj.sdutacm.cn\\u002F"
4513+
},
45094514
vjudge: {
45104515
title: "VJudge",
45114516
description: "virtual judge,这个OJ的题量是单独计算的",
@@ -4594,7 +4599,7 @@ exports[`/login 1`] = `
45944599
<head>
45954600
<meta data-n-head="ssr" charset="utf-8">
45964601
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
4597-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
4602+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
45984603
<title>OJ Analyzer</title>
45994604
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
46004605
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -5456,7 +5461,7 @@ exports[`/register 1`] = `
54565461
<head>
54575462
<meta data-n-head="ssr" charset="utf-8">
54585463
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
5459-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
5464+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
54605465
<title>OJ Analyzer</title>
54615466
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
54625467
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -6342,7 +6347,7 @@ exports[`/settings 1`] = `
63426347
<head>
63436348
<meta data-n-head="ssr" charset="utf-8">
63446349
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
6345-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
6350+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
63466351
<title>Settings - OJ Analyzer</title>
63476352
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
63486353
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -7341,7 +7346,7 @@ exports[`/statistics 1`] = `
73417346
<head>
73427347
<meta data-n-head="ssr" charset="utf-8">
73437348
<meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1">
7344-
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, VJudge">
7349+
<meta data-n-head="ssr" data-hid="description" name="description" content="An online tool (crawler) to analyze users performance in online judges (coding competition websites). Supported OJ: POJ, HDU, ZOJ, HYSBZ, CodeForces, UVA, ICPC Live Archive, FZU, SPOJ, Timus (URAL), LeetCode_CN, CSU, LibreOJ, 洛谷, 牛客OJ, Lutece (UESTC), AtCoder, AIZU, CodeChef, El Judge, BNUOJ, Codewars, UOJ, NBUT, 51Nod, DMOJ, SDUT OJ, VJudge">
73457350
<title>Statistics - OJ Analyzer</title>
73467351
<link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico">
73477352
<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,400,500,700">
@@ -8137,7 +8142,7 @@ exports[`/statistics 1`] = `
81378142
</div>
81388143
</div>
81398144
<script>
8140-
window.__NUXT__ = (function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I) {
8145+
window.__NUXT__ = (function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J) {
81418146
return {
81428147
layout: "default",
81438148
data: [{}],
@@ -8424,6 +8429,16 @@ exports[`/statistics 1`] = `
84248429
tokenKey: c,
84258430
solvedList: [],
84268431
submissionsByCrawlerName: e
8432+
}, {
8433+
crawlerName: H,
8434+
username: a,
8435+
status: d,
8436+
solved: b,
8437+
submissions: b,
8438+
errorMessage: a,
8439+
tokenKey: c,
8440+
solvedList: [],
8441+
submissionsByCrawlerName: e
84278442
}],
84288443
crawlers: {
84298444
poj: {
@@ -8489,7 +8504,7 @@ exports[`/statistics 1`] = `
84898504
leetcode_cn: {
84908505
title: "LeetCode_CN",
84918506
description: c,
8492-
url: "https:\\u002F\\u002Fleetcode-cn.com",
8507+
url: "https:\\u002F\\u002Fleetcode.cn",
84938508
name: q
84948509
},
84958510
csu: {
@@ -8582,18 +8597,24 @@ exports[`/statistics 1`] = `
85828597
url: "https:\\u002F\\u002Fdmoj.ca\\u002F",
85838598
name: F
85848599
},
8600+
sdutoj: {
8601+
title: "SDUT OJ",
8602+
description: c,
8603+
url: "https:\\u002F\\u002Foj.sdutacm.cn\\u002F",
8604+
name: G
8605+
},
85858606
vjudge: {
85868607
title: "VJudge",
85878608
description: "virtual judge,这个OJ的题量是单独计算的",
85888609
url: "https:\\u002F\\u002Fvjudge.net\\u002F",
8589-
virtual_judge: H,
8590-
name: G
8610+
virtual_judge: I,
8611+
name: H
85918612
}
85928613
},
85938614
mainUsername: a
85948615
}
85958616
},
8596-
serverRendered: H,
8617+
serverRendered: I,
85978618
routePath: "\\u002Fstatistics",
85988619
config: {
85998620
_app: {
@@ -8603,11 +8624,11 @@ exports[`/statistics 1`] = `
86038624
}
86048625
},
86058626
env: {
8606-
VERSION_NUM: I,
8607-
BUILD_TIME: I
8627+
VERSION_NUM: J,
8628+
BUILD_TIME: J
86088629
}
86098630
}
8610-
}("", 0, null, "WAITING", void 0, false, "poj", "hdu", "zoj", "dashiye", "codeforces", "uva", "uvalive", "fzu", "spoj", "timus", "leetcode_cn", "csu", "loj", "luogu", "nowcoder", "uestc", "atcoder", "aizu", "codechef", "eljudge", "bnu", "codewars", "uoj", "nbut", "nod", "dmoj", "vjudge", true, "0"));
8631+
}("", 0, null, "WAITING", void 0, false, "poj", "hdu", "zoj", "dashiye", "codeforces", "uva", "uvalive", "fzu", "spoj", "timus", "leetcode_cn", "csu", "loj", "luogu", "nowcoder", "uestc", "atcoder", "aizu", "codechef", "eljudge", "bnu", "codewars", "uoj", "nbut", "nod", "dmoj", "sdutoj", "vjudge", true, "0"));
86118632
</script>
86128633

86138634

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"data":{"userProfilePublicProfile":{"submissionProgress":{"totalSubmissions":4,"acTotal":2}}}}
1+
{"data":{"userProfileUserQuestionSubmitStats":{"acSubmissionNum":[{"difficulty":"EASY","count":1},{"difficulty":"MEDIUM","count":1},{"difficulty":"HARD","count":0}],"totalSubmissionNum":[{"difficulty":"EASY","count":2},{"difficulty":"MEDIUM","count":2},{"difficulty":"HARD","count":0}]}}}

e2e/cypress/integration/frontend/history.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ before(() => {
1515

1616
// FIXME: the two route below do not work in intercept
1717
cy.server()
18-
cy.route('post', 'https://cors.ojhunt.com/https://leetcode-cn.com/graphql',
18+
cy.route('post', 'https://cors.ojhunt.com/https://leetcode.cn/graphql/',
1919
'fixture:summary_leetcode.txt')
2020
.as('summary_leetcode')
2121
cy.route('/api/crawlers/vjudge/wwwlsmcom',
-27 Bytes
Loading
-29 Bytes
Loading
-38 Bytes
Loading
Loading
-62 Bytes
Loading

0 commit comments

Comments
 (0)