python - 将 python tweepy api.trends_place 列表值导出到 pygsheets 表
问题描述
我有两个功能代码片段:一个用于从 Twitter 中提取趋势,另一个用于连接到数据库(有关其他上下文,请参见下文)。我正在寻找的是从“趋势”中获取值并将其粘贴到工作表“趋势”中。我应该补充说trend_place返回一个 JSON 对象。
不用说,我刚刚开始使用 python,我的一般编码经验几乎不存在。
#This is the end of the Twitter trends code. Using tweepy amongst others libs, ATM it returns in console the trends via print
# fetching the trends
trends = api.trends_place(id=woeid)
# printing the information
print("The top trends for the location are :")
for value in trends:
for trend in value['trends']:
print(trend['name'])
twTrends()
#This is the end of the code that links to my spreadsheet. Using pygsheets I have managed to reference down to the desired worksheet: "Trends".
sheet = client.open_by_key(id)
wks = sheet.worksheet('title','Trends')
解决方案
推荐阅读
- c# - 以编程方式 Godaddy 发送的电子邮件不在“已发送邮件”文件夹中 C#.net
- python - 枚举列表中具有相似字符串的函数
- python - 如何使用 Django 在请求之间持久化数据
- python - 使用 pywin32 找出 com 对象的 ProgID
- c# - 递增 t2 变量
- html - 如何获取传递给两个不同函数的文本框的值
- xamarin - Xamarin - 迁移到 AndroidX 后恢复包失败
- mysql - 将数据 infile 加载到特定列中
- regex - 正则表达式:获取特定大写字母之间的文本
- r - 当 TRUE 在 R 中的单独向量中的相同位置时,如何创建一个重复值的序列?