-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
import pywencai | ||
import os | ||
|
||
# 获取环境变量的值 | ||
keywords = os.environ.get("KEYWORDS", []) | ||
# 将列表转换为字符串,使用逗号进行连接 | ||
keywords_str = ",".join(keywords) | ||
# 获取关键字列表 | ||
keywords = os.environ.get("KEYWORD", "").split(',') | ||
|
||
# 检查关键字是否为空 | ||
if keywords_str: | ||
# 拆分关键字字符串为列表 | ||
keywords = keywords_str.split(",") | ||
|
||
# 遍历关键字列表进行查询和保存结果 | ||
for keyword in keywords: | ||
filename = f'{keyword}.csv' | ||
res = pywencai.get(question=keyword, loop=True) | ||
res.to_csv(filename, index=False, encoding='utf-8-sig') | ||
print(res) | ||
else: | ||
print("No keywords found.") | ||
# 遍历关键字列表进行查询和保存结果 | ||
for keyword in keywords: | ||
filename = f'{keyword}.csv' | ||
res = pywencai.get(question=keyword, loop=True) | ||
res.to_csv(filename, index=False, encoding='utf-8-sig') | ||
print(res) |