Skip to content

Commit

Permalink
Update popularity.py
Browse files Browse the repository at this point in the history
  • Loading branch information
qqhsx authored May 27, 2024
1 parent 08fd5c5 commit 83fb87f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions popularity.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import pywencai
import os

# 获取关键字列表
keywords = os.getenv.get("KEYWORDS", []).split(",")
# 获取环境变量的值
keywords = os.environ.get("KEYWORDS", [])
# 将列表转换为字符串,使用逗号进行连接
keywords_str = ",".join(keywords)

# 遍历关键字列表进行查询和保存结果
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)
# 检查关键字是否为空
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.")

0 comments on commit 83fb87f

Please sign in to comment.