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 3c723b7 commit bde664e
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions popularity.py
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)

0 comments on commit bde664e

Please sign in to comment.