Skip to content

Commit

Permalink
perf: check seesion timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles94jp committed Apr 6, 2022
1 parent c76c8a6 commit a2647bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cnblogs_downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import re
import sys
import threading
from datetime import datetime

Expand Down Expand Up @@ -44,6 +45,10 @@ 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()

flag_path = rf"{workdir}\{self._FLAG_FILE_NAME}"
if os.path.isfile(flag_path):
Expand Down
17 changes: 9 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@



# Table of Contents
## Table of Contents

- [Usage](#usage)
- [Configuration](#configuration)
Expand All @@ -30,23 +30,24 @@

- [Links](#links)

# Usage
## Usage

## Configuration
### Configuration

运行前需要配置`config.ini`

1. 修改`config.ini.example`文件名为`config.ini`,使用文本编辑器打开
2. 打开浏览器登录博客园后台,登录时勾选"记住我"
3. 登录后浏览器按F12,找到Cookie,拷贝`.Cnblogs.AspNetCore.Cookies`的值到`config.ini`
<img src="./img/cookie.png" width ="660px">

4. 其余选项按需填写,文件需以UTF-8编码保存

开启离线后,随笔中的图片链接会被替换自动为本地图片的链接



## Dependencies
### Dependencies

运行`pip install`前需关闭系统全局代理

Expand All @@ -56,7 +57,7 @@ pip install httpx



## Start
### Start

配置好程序并安装好httpx依赖后,命令行运行:

Expand All @@ -72,7 +73,7 @@ python main.py



## Features
### Features

下载的文件名为随笔标题,分类和标题中的特殊字符`\/:*?"<>|`会被空格代替,文件编码为UTF-8

Expand All @@ -98,7 +99,7 @@ python main.py



# For Developer
## For Developer

博客园公开的api文档:https://api.cnblogs.com/help

Expand Down Expand Up @@ -139,7 +140,7 @@ python main.py



## Document
### Document

本项目API文档:[**Document**](https://charles94jp.github.io/cnblogs-blogger-downloader)

Expand Down

0 comments on commit a2647bb

Please sign in to comment.