【发布时间】:2019-12-17 23:41:03
【问题描述】:
我正在编写一个机器人,我需要搜索我记录的趋势。但是返回的搜索结果只是[],也就是什么都没有。这是代码的粘贴箱。 https://pastebin.com/pkJ2McUq 和一个代码 sn-p。
import tweepy
APIKey=input("API Key, Please.\n")
APIKeysecret=input("And To Confirm, Your Secret Api Key.\n")
AccessToken=input("Your Access Token?\n")
AccessTokenSecret=input("And The Secret Token.\n")
auth = tweepy.OAuthHandler(APIKey, APIKeysecret)
auth.set_access_token(AccessToken, AccessTokenSecret)
with open("TrendsResult/atrendsresults.json", 'w') as atrendssearchresults :
print(api.search('IndividualTrends/0.txt', lang="EN", result_type = "popular"), file=atrendssearchresults)
with open("TrendsResult/btrendsresults.json", 'w') as btrendssearchresults :
print(api.search('IndividualTrends/1.txt', lang="EN", result_type = "popular"), file=btrendssearchresults)
with open("TrendsResult/ctrendsresults.json", 'w') as ctrendssearchresults :
print(api.search('IndividualTrends/2.txt', lang="EN", result_type = "popular"), file=ctrendssearchresults)
with open("TrendsResult/dtrendsresults.json", 'w') as dtrendssearchresults :
print(api.search('IndividualTrends/3.txt', lang="EN", result_type = "popular"), file=dtrendssearchresults)
with open("TrendsResult/etrendsresults.json", 'w') as etrendssearchresults :
print(api.search('IndividualTrends/4.txt', lang="EN", result_type = "popular"), file=etrendssearchresults)
with open("TrendsResult/ftrendsresults.json", 'w') as ftrendssearchresults :
print(api.search('IndividualTrends/5.txt', lang="EN", result_type = "popular"), file=ftrendssearchresults)
with open("TrendsResult/gtrendsresults.json", 'w') as gtrendssearchresults :
print(api.search('IndividualTrends/6.txt', lang="EN", result_type = "popular"), file=gtrendssearchresults)
with open("TrendsResult/htrendsresults.json", 'w') as htrendssearchresults :
print(api.search('IndividualTrends/7.txt', lang="EN", result_type = "popular"), file=htrendssearchresults)
with open("TrendsResult/itrendsresults.json", 'w') as itrendssearchresults :
print(api.search('IndividualTrends/8.txt', lang="EN", result_type = "popular"), file=itrendssearchresults)
with open("TrendsResult/jtrendsresults.json", 'w') as jtrendssearchresults :
print(api.search('IndividualTrends/j.txt', lang="EN", result_type = "popular"), file=jtrendssearchresults)
我该如何解决?
【问题讨论】: