diff --git a/cnblogs_downloader.py b/cnblogs_downloader.py index dc01f21..52409d6 100644 --- a/cnblogs_downloader.py +++ b/cnblogs_downloader.py @@ -45,10 +45,11 @@ def __init__(self, cnblogs_cookie, workdir, download_img=False): "Referer": "https://i.cnblogs.com/", "Cookie": rf".Cnblogs.AspNetCore.Cookies={cnblogs_cookie}"} self._category = api.get_category_list(self._http_headers) - errors = self._category.get("errors1") - if errors is not None and errors[0] == "Unauthorized": - print("Cookie 已过期,请重新配置Cookie") - sys.exit() + if type(self._category) == dict: + errors = self._category.get("errors1") + if errors is not None and errors[0] == "Unauthorized": + print("Cookie 已过期,请重新配置Cookie") + sys.exit() flag_path = rf"{workdir}\{self._FLAG_FILE_NAME}" if os.path.isfile(flag_path): diff --git a/docs/lib/cnblogs-apiDoc.html b/docs/lib/cnblogs-apiDoc.html index 3a880ae..fc3f07c 100644 --- a/docs/lib/cnblogs-apiDoc.html +++ b/docs/lib/cnblogs-apiDoc.html @@ -3,7 +3,7 @@
-博客园API文档,非官方文档,从博客园后台的网络通信过程中总结
请求方式: GET
请求地址: https://i.cnblogs.com/api/category/blog/1/edit
参数列表:
参数名 | 类型 | 必须 | 描述 | 示例 |
---|---|---|---|---|
/ |
详细说明: 根据用户Cookie获取用户的随笔分类的列表
请求示例:
1https://i.cnblogs.com/api/category/blog/1/edit
返回示例:
xxxxxxxxxx
111[
2 {
3 "categoryId": 1895777,
4 "title": "Bug Solution",
5 "visible": true,
6 "description": "Windows、Linux使用过程中的bug解决办法",
7 "updateTime": "2022-01-08T21:45:04.607",
8 "count": 3,
9 "order": null
10 }
11]
请求方式: GET
请求地址: https://i.cnblogs.com/api/posts/list
参数列表:
参数名 | 类型 | 必须 | 描述 | 示例 |
---|---|---|---|---|
p | int | 是 | 页数,第几页 | 1 |
cid | int | 否 | 分类id,获取分类下的文章。空为所有文章 | 1895777 |
tid | 否 | |||
t | int | 是 | 文章类型:随笔为1,文章为2,日记为128 | 1 |
cfg | 否 | |||
search | 否 | |||
orderBy | 否 | |||
scid | 否 |
详细说明:分页获取用户的随笔列表,每页只能获取10个
请求示例:
xxxxxxxxxx
11https://i.cnblogs.com/api/posts/list?p=1&cid=&tid=&t=1&cfg=0&search=&orderBy=&scid=
返回示例:
xxxxxxxxxx
281{
2 "postList": [
3 {
4 "id": 16013455,
5 "title": "Windows oh my zsh终极解决方案,还得是WSL",
6 "url": "//www.cnblogs.com/yunmuq/p/16013455.html",
7 "isPublished": false,
8 "isDraft": true,
9 "feedBackCount": 0,
10 "webCount": 0,
11 "aggCount": 0,
12 "viewCount": 0,
13 "datePublished": "2022-03-16T16:51:00",
14 "entryName": null,
15 "postType": 1,
16 "postConfig": 16888,
17 "dateUpdated": "2022-03-17T15:40:00",
18 "accessPermission": 0,
19 "isInSiteHome": false,
20 "isInSiteCandidate": false,
21 "isMarkdown": true
22 }
23 ],
24 "postsCount": 46,
25 "pageIndex": 1,
26 "pageSize": 10,
27 "categoryName": ""
28}
请求方式: GET
请求地址:https://i.cnblogs.com/api/posts/{id}
参数列表:
参数名 | 类型 | 必须 | 描述 | 示例 |
---|---|---|---|---|
id | int | 是 | 随笔id | 15980094 |
详细说明:分页获取用户的随笔列表,每页只能获取10个
请求示例:
xxxxxxxxxx
11https://i.cnblogs.com/api/posts/15980094
返回示例:
xxxxxxxxxx
531{
2 "blogPost": {
3 "id": 15980094,
4 "postType": 1,
5 "accessPermission": 0,
6 "title": "【教程】电脑怎么禁用主板蓝牙,使用蓝牙适配器?",
7 "url": "//www.cnblogs.com/yunmuq/p/15980094.html",
8 "postBody": "<br></br>\n有时主板蓝牙出毛病,比如蓝牙耳机播放卡顿,蓝牙版本过低等,购买了新的USB蓝牙适配器,怎么正确使用呢?...",
9 "categoryIds": [
10 1899874
11 ],
12 "inSiteCandidate": false,
13 "inSiteHome": false,
14 "siteCategoryId": null,
15 "blogTeamIds": [],
16 "isPublished": true,
17 "displayOnHomePage": true,
18 "isAllowComments": true,
19 "includeInMainSyndication": true,
20 "isPinned": false,
21 "isOnlyForRegisterUser": false,
22 "isUpdateDateAdded": false,
23 "entryName": null,
24 "description": "",
25 "featuredImage": null,
26 "tags": [],
27 "password": null,
28 "datePublished": "2022-03-08T13:52:00",
29 "isMarkdown": true,
30 "isDraft": false,
31 "autoDesc": "有时主板蓝牙出毛病,比如蓝牙耳机播放卡顿,蓝牙版本过低等,购买了新的USB蓝牙适配器,怎么",
32 "changePostType": false,
33 "blogId": 650454,
34 "author": "云牧青",
35 "removeScript": false,
36 "clientInfo": null,
37 "changeCreatedTime": false,
38 "canChangeCreatedTime": false,
39 "isContributeToImpressiveBugActivity": false
40 },
41 "myConfig": {
42 "canInSiteCandidate": false,
43 "noSiteCandidateMsg": "发布时间超过10小时的随笔不能投稿到首页候选区",
44 "canInSiteHome": false,
45 "noSiteHomeMsg": "发布时间超过1小时的随笔不能投稿到网站首页",
46 "myTeamCollection": [],
47 "editor": {
48 "id": 5,
49 "host": "//common.cnblogs.com",
50 "cdnRefreshId": null
51 }
52 }
53}
博客园API文档,非官方文档,从博客园后台的网络通信过程中总结
请求方式: GET
请求地址: https://i.cnblogs.com/api/category/blog/1/edit
参数列表:
参数名 | 类型 | 必须 | 描述 | 示例 |
---|---|---|---|---|
/ |
详细说明: 根据用户Cookie获取用户的随笔分类的列表
请求示例:
1https://i.cnblogs.com/api/category/blog/1/edit
成功返回示例:
xxxxxxxxxx
111[
2 {
3 "categoryId": 1895777,
4 "title": "Bug Solution",
5 "visible": true,
6 "description": "Windows、Linux使用过程中的bug解决办法",
7 "updateTime": "2022-01-08T21:45:04.607",
8 "count": 3,
9 "order": null
10 }
11]
未授权返回示例:
x
1{
2 "errors": [
3 "Unauthorized"
4 ],
5 "type": 1
6}
请求方式: GET
请求地址: https://i.cnblogs.com/api/posts/list
参数列表:
参数名 | 类型 | 必须 | 描述 | 示例 |
---|---|---|---|---|
p | int | 是 | 页数,第几页 | 1 |
cid | int | 否 | 分类id,获取分类下的文章。空为所有文章 | 1895777 |
tid | 否 | |||
t | int | 是 | 文章类型:随笔为1,文章为2,日记为128 | 1 |
cfg | 否 | |||
search | 否 | |||
orderBy | 否 | |||
scid | 否 |
详细说明:分页获取用户的随笔列表,每页只能获取10个
请求示例:
xxxxxxxxxx
11https://i.cnblogs.com/api/posts/list?p=1&cid=&tid=&t=1&cfg=0&search=&orderBy=&scid=
返回示例:
xxxxxxxxxx
281{
2 "postList": [
3 {
4 "id": 16013455,
5 "title": "Windows oh my zsh终极解决方案,还得是WSL",
6 "url": "//www.cnblogs.com/yunmuq/p/16013455.html",
7 "isPublished": false,
8 "isDraft": true,
9 "feedBackCount": 0,
10 "webCount": 0,
11 "aggCount": 0,
12 "viewCount": 0,
13 "datePublished": "2022-03-16T16:51:00",
14 "entryName": null,
15 "postType": 1,
16 "postConfig": 16888,
17 "dateUpdated": "2022-03-17T15:40:00",
18 "accessPermission": 0,
19 "isInSiteHome": false,
20 "isInSiteCandidate": false,
21 "isMarkdown": true
22 }
23 ],
24 "postsCount": 46,
25 "pageIndex": 1,
26 "pageSize": 10,
27 "categoryName": ""
28}
请求方式: GET
请求地址:https://i.cnblogs.com/api/posts/{id}
参数列表:
参数名 | 类型 | 必须 | 描述 | 示例 |
---|---|---|---|---|
id | int | 是 | 随笔id | 15980094 |
详细说明:分页获取用户的随笔列表,每页只能获取10个
请求示例:
xxxxxxxxxx
11https://i.cnblogs.com/api/posts/15980094
返回示例:
xxxxxxxxxx
531{
2 "blogPost": {
3 "id": 15980094,
4 "postType": 1,
5 "accessPermission": 0,
6 "title": "【教程】电脑怎么禁用主板蓝牙,使用蓝牙适配器?",
7 "url": "//www.cnblogs.com/yunmuq/p/15980094.html",
8 "postBody": "<br></br>\n有时主板蓝牙出毛病,比如蓝牙耳机播放卡顿,蓝牙版本过低等,购买了新的USB蓝牙适配器,怎么正确使用呢?...",
9 "categoryIds": [
10 1899874
11 ],
12 "inSiteCandidate": false,
13 "inSiteHome": false,
14 "siteCategoryId": null,
15 "blogTeamIds": [],
16 "isPublished": true,
17 "displayOnHomePage": true,
18 "isAllowComments": true,
19 "includeInMainSyndication": true,
20 "isPinned": false,
21 "isOnlyForRegisterUser": false,
22 "isUpdateDateAdded": false,
23 "entryName": null,
24 "description": "",
25 "featuredImage": null,
26 "tags": [],
27 "password": null,
28 "datePublished": "2022-03-08T13:52:00",
29 "isMarkdown": true,
30 "isDraft": false,
31 "autoDesc": "有时主板蓝牙出毛病,比如蓝牙耳机播放卡顿,蓝牙版本过低等,购买了新的USB蓝牙适配器,怎么",
32 "changePostType": false,
33 "blogId": 650454,
34 "author": "云牧青",
35 "removeScript": false,
36 "clientInfo": null,
37 "changeCreatedTime": false,
38 "canChangeCreatedTime": false,
39 "isContributeToImpressiveBugActivity": false
40 },
41 "myConfig": {
42 "canInSiteCandidate": false,
43 "noSiteCandidateMsg": "发布时间超过10小时的随笔不能投稿到首页候选区",
44 "canInSiteHome": false,
45 "noSiteHomeMsg": "发布时间超过1小时的随笔不能投稿到网站首页",
46 "myTeamCollection": [],
47 "editor": {
48 "id": 5,
49 "host": "//common.cnblogs.com",
50 "cdnRefreshId": null
51 }
52 }
53}