添加自主开发文档
This commit is contained in:
parent
8ec55edd2a
commit
c88316328c
40
开发文档/自主开发文档.md
Normal file
40
开发文档/自主开发文档.md
Normal file
@ -0,0 +1,40 @@
|
||||
### 个人监测源接入
|
||||
#### 配置信息
|
||||
- 路径:./config/
|
||||
- 配置输出:参考下面函数
|
||||
```python
|
||||
def get_debug_config(): # 函数名称,获取调试配置信息
|
||||
with open('./config/config.yaml', 'r', encoding="utf-8") as file: # 获取配置文件路径
|
||||
config = yaml.safe_load(file)
|
||||
debug = f"{config['debug']}" # 加载需要的配置
|
||||
|
||||
return debug # 返回配置信息
|
||||
```
|
||||
|
||||
#### 爬虫程序
|
||||
- 路径:./spider/
|
||||
- 开发方法:使用普通爬虫程序,然后提取其中的有用信息以json格式存储于./resources/JSON/中
|
||||
|
||||
#### 分析程序
|
||||
- 路径:./GotoSend/
|
||||
- 开发方法:将json文件中各元素依次存储于./resources/db/内(利用sqlite技术,存储过程中记得将时间格式化:年月日 时分秒),使用cursor查询数据库中符合筛选条件的文章,最后构造发送文本,以markdown+数列的形式返回(return)。
|
||||
###### 注意事项:RSS类订阅信息大多结构类似,仅需复制其他RSS源爬虫(如common.py)进行保留字段删改即可,在分析模块中仅需处理时间格式并且注意字段的删改即可复用,然后可以现在单独创建函数,也可以选择合并入send_job_RSS函数中
|
||||
|
||||
#### 核心程序
|
||||
- 路径:./Core.py
|
||||
- 开发方法:先引入爬虫和分析模块(import),直接创建新函数,然后再main_loop函数中执行即可
|
||||
参考代码:
|
||||
```python
|
||||
from config.check_config import get_core_config, get_debug_config, get_kewords_config # 引入配置信息
|
||||
from spider.sougou_wx import sougou_wx_main # 引入爬虫模块
|
||||
from GotoSend.sougou_wx import Src_sougou_wx # 引入分析模块
|
||||
|
||||
def send_job_SX(): # 创建新函数
|
||||
Sogou_WX = get_kewords_config('Sogou_WX') # 获取配置信息
|
||||
sougou_wx_main(Sogou_WX) # 爬虫爬取信息
|
||||
result_sx_long = Src_sougou_wx(False) # 获取长文本信息
|
||||
result_sx_short = Src_sougou_wx(True) # 获取短文本信息
|
||||
webhook_url, timestamp, sign = gen_sign() # 飞书时间密钥生成
|
||||
check_avaliable(result_sx_long, result_sx_short, "微信公众号关键词相关内容", webhook_url, timestamp, sign) # 进入筛选程序分发到各渠道
|
||||
```
|
||||
- 温馨提示:您还可更改send_first_message函数,使程序的首次运行提示更加符合程序的运行。
|
Loading…
Reference in New Issue
Block a user