Skip to content

Commit d5b2f50

Browse files
committed
update
1 parent 161cf7d commit d5b2f50

File tree

2 files changed

+51
-31
lines changed

2 files changed

+51
-31
lines changed

README.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,20 @@ For related documents, refer to related technologies or query them by yourself.
102102

103103
All interfaces were tested when the document was updated.
104104

105-
- [User Status <sup>with-Cookie</sup>](#User-Status-<sup>with-Cookie</sup>)
106-
- [Question Set <sup>can-without-Cookie</sup>](#Question-Set-<sup>can-without-Cookie</sup>)
107-
- [Question Detail <sup>can-without-Cookie</sup>](#Question-Detail-<sup>can-without-Cookie</sup>)
108-
- [Question Status <sup>with-Cookie</sup>](#Question-Status-<sup>with-Cookie</sup>)
109-
- [Submission ID <sup>with-Cookie-and-fake-referer</sup>](#Submission-ID-<sup>with-Cookie-and-fake-referer</sup>)
105+
- [User Status](#User-Status)
106+
- [Question Set](#Question-Set)
107+
- [Question Detail](#Question-Detail)
108+
- [Question Status](#Question-Status)
109+
- [Submission ID](#Submission-ID)
110110
- [Submission Detail](#Submission-Detail)
111111

112112
Cookie items mentioned in the table below refer to **LEETCODE_SESSION** and **x-csrftoken** items generated when users log in to the official website of Licou. The method of obtaining them is as follows: After logging in successfully using the browser, open the network item in the developer tool and look for the graphQL request in the successful state. The values of the two items can be found in the request information.
113113

114-
> If **with-Cookie** is marked on the interface, the data can be obtained only when the above two cookies are carried for network request. If **can-without-Cookie** is marked on the interface, complete data can be obtained only by carrying the above two cookies for network request (cookies with * in entries can be normally obtained only by carrying cookies). No annotation is an ordinary network request, and complete data can be normally obtained without carrying cookies.
114+
> If **With-Cookie** is marked on the interface, the data can be obtained only when the above two cookies are carried for network request. If **Can-Without-Cookie** is marked on the interface, complete data can be obtained only by carrying the above two cookies for network request (cookies with * in entries can be normally obtained only by carrying cookies). No annotation is an ordinary network request, and complete data can be normally obtained without carrying cookies.
115115
116-
### User Status <sup>with-Cookie</sup>
116+
### User Status
117+
118+
Type[**With-Cookie**]
117119

118120
```javascript
119121
const $leetcode = new $Leetcode()
@@ -157,7 +159,9 @@ Return Data:
157159
| userStatus.userSlug | String | User Slug |
158160
| userStatus.username | String | User name |
159161

160-
### Question Set <sup>can-without-Cookie</sup>
162+
### Question Set
163+
164+
Type[**Can-Without-Cookie**]
161165

162166
```javascript
163167
const $leetcode = new $Leetcode()
@@ -220,7 +224,9 @@ Return Data:
220224
| problemsetQuestionList.questions.topicTags.slug | String | Topic slug |
221225
| problemsetQuestionList.total | Number | Question total number |
222226

223-
### Question Detail <sup>can-without-Cookie</sup>
227+
### Question Detail
228+
229+
Type[**Can-Without-Cookie**]
224230

225231
```javascript
226232
const $leetcode = new $Leetcode()
@@ -298,7 +304,9 @@ Return Data:
298304
| question.translatedTitle | String | Question title(Chinese) |
299305
| question.ugcQuestionId | String | Question UGCID? |
300306

301-
### Question Status <sup>with-Cookie</sup>
307+
### Question Status
308+
309+
Type[**With-Cookie**]
302310

303311
```javascript
304312
const $leetcode = new $Leetcode()
@@ -326,7 +334,9 @@ Return Data:
326334
| allQuestionsBeta.questionId | String | Question ID |
327335
| allQuestionsBeta.status | String | Question Status |
328336

329-
### Submission ID <sup>with-Cookie-and-fake-referer</sup>
337+
### Submission ID
338+
339+
Type[**With-Cookie-and-Fake-Referer**]
330340

331341
```javascript
332342
const $leetcode = new $Leetcode()
@@ -345,7 +355,7 @@ const $leetcode = new $Leetcode()
345355
}) // must with cookie [LEETCODE_SESSION,x-csrftoken] and referer [https://leetcode-cn.com/problems/${questionSlug}/submissions/]
346356
```
347357

348-
> Note that in this Api, Cookies must be carried at `https://leetcode-cn.com/problems/${questionSlug}/submit`, i.e. the URL visited, otherwise the **CSRF** validation of Leetcode will fail. At the same time, the Api also needs to forge the Referer as `https://leetcode-cn.com/problems/${questionSlug}/submissions/`, where the variable questionSlug in the string template is the title, It must be an optional value of `question.TitleSlug` in [Question Details API](#Question-Detail-<sup>can-without-Cookie</sup>)
358+
> Note that in this Api, Cookies must be carried at `https://leetcode-cn.com/problems/${questionSlug}/submit`, i.e. the URL visited, otherwise the **CSRF** validation of Leetcode will fail. At the same time, the Api also needs to forge the Referer as `https://leetcode-cn.com/problems/${questionSlug}/submissions/`, where the variable questionSlug in the string template is the title, It must be an optional value of `question.TitleSlug` in [Question Details API](#Question-Detail)
349359
350360
Request data:
351361

@@ -358,10 +368,10 @@ Request data:
358368

359369
Parameters:
360370

361-
- `question_id`,Question ID, which must be an optional value of `question.QuestionId` in [Question Details API](#Question Detail <sup>can-without-Cookie</sup>).
362-
- `lang`, Question language, which must be an optional value of `question.codeSnippets.langSlug`in [Question Details API](#Question Detail <sup>can-without-Cookie</sup>)
371+
- `question_id`,Question ID, which must be an optional value of `question.QuestionId` in [Question Details API](#Question Detail).
372+
- `lang`, Question language, which must be an optional value of `question.codeSnippets.langSlug`in [Question Details API](#Question Detail)
363373
- `typed_code`, Running code, test the problem solving code that runs.
364-
- `questionSlug`, Question slug, which must be an optional value of `question.titleSlug` in [Question Details API](#Question Detail <sup>can-without-Cookie</sup>)
374+
- `questionSlug`, Question slug, which must be an optional value of `question.titleSlug` in [Question Details API](#Question Detail)
365375
- <s>`test_mode`</s>, test mode.
366376
- <s>`test_judger`</s>, test judger.
367377

@@ -394,7 +404,7 @@ Request data:
394404

395405
Parameters:
396406

397-
- `submission_id`,Submission ID, which must be an optional value of `submission_id` in [Submission ID API](#Submission-ID-<sup>with-Cookie-and-fake-referer</sup>).
407+
- `submission_id`,Submission ID, which must be an optional value of `submission_id` in [Submission ID API](#Submission-ID).
398408

399409
Return Data:
400410

README.zh.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,20 @@ const { session } = remote
9696

9797
所有接口在文档更新时均已通过测试。
9898

99-
- [用户状态 <sup>必须使用Cookie</sup>](#用户状态-<sup>必须使用Cookie</sup>)
100-
- [题目集合 <sup>可以不使用Cookie</sup>](#题目集合-<sup>可以不使用Cookie</sup>)
101-
- [题目详情 <sup>可以不使用Cookie</sup>](#题目详情-<sup>可以不使用Cookie</sup>)
102-
- [题目状态 <sup>必须使用Cookie</sup>](#题目状态-<sup>必须使用Cookie</sup>)
103-
- [提交ID <sup>必须使用Cookie、伪造referer</sup>](#提交ID-<sup>必须使用Cookie、伪造referer</sup>)
99+
- [用户状态](#用户状态)
100+
- [题目集合](#题目集合)
101+
- [题目详情](#题目详情)
102+
- [题目状态](#题目状态)
103+
- [提交ID](#提交ID)
104104
- [提交详情](#提交详情)
105105

106106
下文表格中提到的 Cookie 项,是指用户在登录力扣官方网站生成的 **LEETCODE_SESSION****x-csrftoken** 项,获取方法:使用浏览器登录成功后,打开开发人员工具中的网络一项,寻找成功状态的 graphql 请求,在请求信息中可以找到这两项的值。
107107

108108
> 接口中标注 `必须使用Cookie` 时,即必须携带上述两项 Cookie 进行网络请求才能获取到数据;接口中标注 `可以不使用Cookie` 时,即携带上述两项 Cookie 进行网络请求才能获取到完整数据(表项中带有 * 的需要携带 Cookie 才能正常获取);无标注即为普通的网络请求,不需要携带 Cookie 也能正常获取到完整数据。
109109
110-
### 用户状态 <sup>必须使用Cookie</sup>
110+
### 用户状态
111+
112+
! **必须使用Cookie**
111113

112114
```javascript
113115
const $leetcode = new $Leetcode()
@@ -151,7 +153,9 @@ const $leetcode = new $Leetcode()
151153
| userStatus.userSlug | String | 用户标签 |
152154
| userStatus.username | String | 用户名 |
153155

154-
### 题目集合 <sup>可以不使用Cookie</sup>
156+
### 题目集合
157+
158+
! **可以不使用Cookie**
155159

156160
```javascript
157161
const $leetcode = new $Leetcode()
@@ -214,7 +218,9 @@ const $leetcode = new $Leetcode()
214218
| problemsetQuestionList.questions.topicTags.slug | String | 话题标题 |
215219
| problemsetQuestionList.total | Number | 题目总数 |
216220

217-
### 题目详情 <sup>可以不使用Cookie</sup>
221+
### 题目详情
222+
223+
! **可以不使用Cookie**
218224

219225
```javascript
220226
const $leetcode = new $Leetcode()
@@ -292,7 +298,9 @@ const $leetcode = new $Leetcode()
292298
| question.translatedTitle | String | 题目题名(中文) |
293299
| question.ugcQuestionId | String | 未知,题目UGCID? |
294300

295-
### 题目状态 <sup>必须使用Cookie</sup>
301+
### 题目状态
302+
303+
! **必须使用Cookie**
296304

297305
```javascript
298306
const $leetcode = new $Leetcode()
@@ -320,7 +328,9 @@ const $leetcode = new $Leetcode()
320328
| allQuestionsBeta.questionId | String | 题目ID |
321329
| allQuestionsBeta.status | String | 题目状态 |
322330

323-
### 提交ID <sup>必须使用Cookie、伪造referer</sup>
331+
### 提交ID
332+
333+
! **必须使用Cookie、伪造referer**
324334

325335
```javascript
326336
const $leetcode = new $Leetcode()
@@ -339,7 +349,7 @@ const $leetcode = new $Leetcode()
339349
}) // must with cookie [LEETCODE_SESSION,x-csrftoken] and referer [https://leetcode-cn.com/problems/${questionSlug}/submissions/]
340350
```
341351

342-
> 注意,在这个 Api 中,Cookies 必须被携带在 `https://leetcode-cn.com/problems/${questionSlug}/submit`,即访问的 URL ,否则会触发力扣的 **CSRF** 校验失败。同时,此 Api 还需要伪造 Referer 为 `https://leetcode-cn.com/problems/${questionSlug}/submissions/`,其中字符串模板中的变量 questionSlug 为题目标题,必须为 [题目详情 API](#题目详情-<sup>可以不使用Cookie</sup>)`question.titleSlug` 的可选值
352+
> 注意,在这个 Api 中,Cookies 必须被携带在 `https://leetcode-cn.com/problems/${questionSlug}/submit`,即访问的 URL ,否则会触发力扣的 **CSRF** 校验失败。同时,此 Api 还需要伪造 Referer 为 `https://leetcode-cn.com/problems/${questionSlug}/submissions/`,其中字符串模板中的变量 questionSlug 为题目标题,必须为 [题目详情 API](#题目详情)`question.titleSlug` 的可选值
343353
344354
请求数据项:
345355

@@ -352,10 +362,10 @@ const $leetcode = new $Leetcode()
352362

353363
参数项:
354364

355-
- `question_id`,题目ID,必须是 [题目详情API](#题目详情-<sup>可以不使用Cookie</sup>)`question.questionId` 的可选值。
356-
- `lang`,题目语言,必须是 [题目详情API](#题目详情-<sup>可以不使用Cookie</sup>)`question.codeSnippets.langSlug` 的可选值。
365+
- `question_id`,题目ID,必须是 [题目详情API](#题目详情)`question.questionId` 的可选值。
366+
- `lang`,题目语言,必须是 [题目详情API](#题目详情)`question.codeSnippets.langSlug` 的可选值。
357367
- `typed_code`,运行代码,将测试运行的题解代码。
358-
- `questionSlug`,题目标题,必须是 [题目详情API](#题目详情-<sup>可以不使用Cookie</sup>)`question.titleSlug` 的可选值。
368+
- `questionSlug`,题目标题,必须是 [题目详情API](#题目详情)`question.titleSlug` 的可选值。
359369
- <s>`test_mode`</s>,测试模式。
360370
- <s>`test_judger`</s>,测试判定器。
361371

@@ -388,7 +398,7 @@ const $leetcode = new $Leetcode()
388398

389399
参数项:
390400

391-
- `submission_id`,题目ID,必须是 [提交ID API](#提交ID-<sup>必须使用Cookie、伪造referer</sup>)`submission_id` 的可选值。
401+
- `submission_id`,题目ID,必须是 [提交ID API](#提交ID)`submission_id` 的可选值。
392402

393403
获取到的数据项:
394404

0 commit comments

Comments
 (0)