Skip to content

Commit d6ffb61

Browse files
committed
Add support for YAML configuration files
Now the path of the configuration file is fixed to config.yml.
1 parent 1f300ed commit d6ffb61

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

auto_comment_plus.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
import requests
1010
from lxml import etree
1111
import jdspider
12+
import yaml
13+
14+
CONFIG_PATH = './config.yml'
1215

1316
jieba.setLogLevel(jieba.logging.INFO)
1417
"""
1518
ck填到下面就好,只支持网页版的Ck
1619
以下为最短格式
1720
"""
18-
ck = ''
21+
with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
22+
cfg = yaml.safe_load(f)
23+
ck = cfg['user']['cookie']
1924

2025
headers = {
2126
'cookie': ck,

config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
user:
2+
cookie: ''

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
jieba
22
requests
33
lxml
4-
zhon
4+
zhon
5+
pyyaml

0 commit comments

Comments
 (0)