update
This commit is contained in:
1 parent
50b3bacd4c
commit
2655151c24
53 files changed
+6905
-309
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
-6
@@ -11,12 +11,8 @@ headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Cache-Control": "no-cache",
|
||||
"Upgrade-Insecure-Requests": "1",
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"Sec-Fetch-Site": "same-origin",
|
||||
"Sec-Fetch-Mode": "navigate",
|
||||
"Sec-Fetch-User": "?1",
|
||||
"Sec-Fetch-Dest": "document",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9"
|
||||
}
|
||||
|
||||
@@ -44,7 +40,7 @@ def fetch_rss(url, headers, timeout=60):
|
||||
logger.warning(f"请求 {url} 超时,跳过保存操作。")
|
||||
return None
|
||||
except RequestException as e:
|
||||
logger.error(f"请求 {url} 时发生错误: {e}")
|
||||
logger.warning(f"请求 {url} 时发生错误: {e}")
|
||||
return None # 返回None表示请求失败
|
||||
|
||||
def parse_rss(rss_content):
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ def fetch_rss(url, headers, timeout=20):
|
||||
logger.warning(f"请求 {url} 超时,跳过保存操作。")
|
||||
return None
|
||||
except RequestException as e:
|
||||
logger.error(f"请求 {url} 时发生错误: {e}")
|
||||
logger.warning(f"请求 {url} 时发生错误: {e}")
|
||||
return None # 返回None表示请求失败
|
||||
|
||||
def parse_rss(rss_content):
|
||||
@@ -68,7 +68,7 @@ def freebuf_main():
|
||||
save_to_json(items, './resources/JSON/freebuf.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/freebuf.json!")
|
||||
except Exception as e:
|
||||
logger.error(f"解析或保存Freebuf RSS内容时发生错误: {e}")
|
||||
logger.warning(f"解析或保存Freebuf RSS内容时发生错误: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
freebuf_main()
|
||||
+16
-8
@@ -12,9 +12,17 @@ MAX_DESCRIPTION_LENGTH = 300
|
||||
|
||||
with open('./config/github_config.yaml', 'r', encoding="utf-8") as file:
|
||||
config = yaml.safe_load(file)
|
||||
# list = yaml.load(f,Loader=yaml.FullLoader)
|
||||
token = config['github_token']
|
||||
tool_list, keyword_list, user_list, black_words = config['tool_list'], config['keyword_list'], config['user_list'], config['black_words']
|
||||
|
||||
def load_github_config():
|
||||
with open('./config/github_config.yaml', 'r', encoding="utf-8") as file:
|
||||
config = yaml.safe_load(file)
|
||||
tool_list = config['tool_list']
|
||||
keyword_list = config['keyword_list']
|
||||
user_list = config['user_list']
|
||||
black_words = config['black_words']
|
||||
|
||||
return keyword_list, tool_list, user_list, black_words
|
||||
|
||||
def fetch_rss(url, timeout=10):
|
||||
if token is None:
|
||||
@@ -35,14 +43,14 @@ def fetch_rss(url, timeout=10):
|
||||
logger.warning(f"请求 {url} 超时,跳过保存操作。")
|
||||
return None
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"请求 {url} 时发生错误: {e}")
|
||||
logger.warning(f"请求 {url} 时发生错误: {e}")
|
||||
return None
|
||||
|
||||
def save_to_json(data, filename):
|
||||
with open(filename, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
def github_main_keyword(key):
|
||||
def github_main_keyword(key, black_words):
|
||||
all_results = [] # 用于存储所有结果
|
||||
for keyword in key:
|
||||
logger.info(f"github_keyword:关键词【{keyword}】获取开始。")
|
||||
@@ -173,7 +181,7 @@ def github_main_release(key):
|
||||
# 将所有结果写入JSON文件
|
||||
save_to_json(all_results, './resources/JSON/github_release.json')
|
||||
|
||||
def github_main_user(key):
|
||||
def github_main_user(key, black_words):
|
||||
all_results = [] # 用于存储所有结果
|
||||
for keyword in key:
|
||||
logger.info(f"github_user:作者【{keyword}】更新情况获取开始。")
|
||||
@@ -223,14 +231,14 @@ def github_main_user(key):
|
||||
# 将所有结果写入JSON文件
|
||||
save_to_json(all_results, './resources/JSON/github_user.json')
|
||||
|
||||
def github_main():
|
||||
def github_main(keyword_list, tool_list, user_list, black_words):
|
||||
if keyword_list:
|
||||
github_main_keyword(keyword_list)
|
||||
github_main_keyword(keyword_list, black_words)
|
||||
if tool_list:
|
||||
github_main_repo(tool_list)
|
||||
github_main_release(tool_list)
|
||||
if user_list:
|
||||
github_main_user(user_list)
|
||||
github_main_user(user_list, black_words)
|
||||
|
||||
if __name__ == "__main__":
|
||||
github_main()
|
||||
+1
-1
@@ -30,7 +30,7 @@ def fetch_html(url, headers=headers, timeout=10):
|
||||
except requests.Timeout:
|
||||
logger.warning(f"请求 {url} 超时,跳过保存操作。")
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"请求 {url} 时发生错误: {e}")
|
||||
logger.warning(f"请求 {url} 时发生错误: {e}")
|
||||
|
||||
def parse_html(html_content):
|
||||
soup = BeautifulSoup(html_content, 'html.parser')
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ def fetch_rss(url, headers, timeout=20):
|
||||
logger.warning(f"请求 {url} 超时,跳过保存操作。")
|
||||
return None
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"请求 {url} 时发生错误: {e}")
|
||||
logger.warning(f"请求 {url} 时发生错误: {e}")
|
||||
return None # 返回None表示请求失败
|
||||
|
||||
# 先知社区 爬虫
|
||||
@@ -66,7 +66,7 @@ def xianzhi_main():
|
||||
|
||||
logger.info("数据已保存到 ./resources/JSON/xianzhi.json!")
|
||||
except Exception as e:
|
||||
logger.error(f"解析或保存先知社区RSS内容时发生错误: {e}")
|
||||
logger.warning(f"解析或保存先知社区RSS内容时发生错误: {e}")
|
||||
|
||||
# 示例调用
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user