请帮帮我!我正在尝试使用免费的tweepy完成一个特定于geo的查询搜索。我意识到,被归还的推特坐标/地点仍然来自世界各地。即使我简化了要调查的代码,geo仍然无法工作:
# Get auth - deleter is a function I made to format .txt into string, note the appauth not oauth.
def startup(loc):
consumer_secret = deleter(open(loc[0],'r').read(),'\n')
consumer_key = deleter(open(loc[1],'r').read(),'\n')
auth = tweepy.AppAuthHandler(consumer_key, consumer_secret)
api = tweepy.API(auth, wait_on_rate_limit=True,
wait_on_rate_limit_notify=True)
if (not api):
print ("Can't Authenticate"),sys.exit(-1)
return api
# Keys
loc = ['consumer_scret.txt', 'api.txt']
api = startup(loc)
# Search parameters
query = "lockdown"
gg = "5.29126,52.132633,10km"
results = api.search(q=query,geo=gg, count = 100)
for tweet in results:
print(tweet.id,tweet.geo,tweet.place,tweet.coordinates)任何帮助都是非常感谢的!
发布于 2020-05-22 13:02:51
我觉得你的地理参数被忽略了。传递给search的参数名是geocode,而不是geo。试试这个:
results = api.search(q=query, geocode=gg, count=100)当我用搜索半径小到10公里的时候,我没有得到任何结果。如果我把半径扩大到1000公里,我会得到更多。
参考: API.search
https://stackoverflow.com/questions/61951868
复制相似问题