add crawling files.

This commit is contained in:
2024-10-23 08:27:29 +08:00
parent a0f9f3ba21
commit a2fb937b8f
15 changed files with 3275 additions and 0 deletions

31
scripts/config.py Normal file
View File

@ -0,0 +1,31 @@
import logging
import os
import inspect
from datetime import datetime
# MySQL 配置
db_config = {
'host': '172.18.0.3',
'user': 'root',
'password': 'mysqlpw',
'database': 'stockdb'
}
# 设置日志配置
def setup_logging(log_filename=None):
# 如果未传入 log_filename则使用当前脚本名称作为日志文件名
if log_filename is None:
# 获取调用 setup_logging 的脚本文件名
caller_frame = inspect.stack()[1]
caller_filename = os.path.splitext(os.path.basename(caller_frame.filename))[0]
# 获取当前日期,格式为 yyyymmdd
current_date = datetime.now().strftime('%Y%m%d')
# 拼接 log 文件名,将日期加在扩展名前
log_filename = f'./log/{caller_filename}_{current_date}.log'
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] (%(funcName)s) - %(message)s',
handlers=[
logging.FileHandler(log_filename),
logging.StreamHandler()
])