You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**This project is for study and exchange only, and under no circumstances shall it be used for any commercial purposes. If you violate the statement, you are responsible for the consequences, and I do not assume any responsibility.**
21
22
22
23
## 项目总览
23
24
24
25
本项目提供的是 **力扣** 官方网站的 **WebApi** 集合,提出的 Api 均已试验成功。
26
+
25
27
This project provides the **WebApi** collection of **Leetcode**, and the proposed Api has been successfully tested.
Leetcode uses [**GraphQL**](https://graphql.org/) technology to obtain data, that is, the mode of **on-demand data distribution**. At the same time, all network requests need to be attached with Cookie access, and some network requests need to confirm whether the **Referer** belongs to Leetcode domain name. Develop a solution before using these WebApis.
46
52
47
53
### 部分解决方案
@@ -60,12 +66,15 @@ In traditional HTML5 projects, such as:
In such projects, due to the safety and risk of forgery of the Referer, it is generally not allowed to modify the items in the HttpRequest header, i.e. the items in the RequestHeader, which contain the Referer item.
In Vue-Cil project, the Webpack **DevProxy** item can be used to set up the relevant request headers, thus creating the effect of faking the Referer for data.
There are many such examples on the Internet, and I won't repeat them all here. Recently, I was writing a new [**Electron**](https://www.electronjs.org/) project, which used the function of forging Referer. Here I can give some examples.
In the given instantiated object, all function methods return [**axios**](https://www.axios-http.cn/) objects. So, you can get data from the function's **then** callback, for example:
86
96
87
97
```javascript
@@ -107,23 +117,28 @@ const { session } = remote,
107
117
```
108
118
109
119
相关的文档请移步相关技术或者自行查询。
120
+
110
121
For related documents, refer to related technologies or query them by yourself.
111
122
112
123
## 接口详情
113
124
114
125
所有接口在文档更新时均已通过测试。
126
+
115
127
All interfaces were tested when the document was updated.
The Cookie items mentioned in the table below refer to the **LEETCODE_SESSION** and **x-csrftoken** items generated when users log in to the official website of Leetcode. 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.
119
132
120
133
### 用户状态
121
134
122
135
```javascript
123
-
$Leetcode.getUserStatus() // with cookie [LEETCODE_SESSION,x-csrftoken]
136
+
const$leetcode=new$Leetcode()
137
+
;$leetcode.getUserStatus() // with cookie [LEETCODE_SESSION,x-csrftoken]
0 commit comments