Python 坐标字段推特流api

Python 坐标字段推特流api,python,json,tweepy,twitter-streaming-api,Python,Json,Tweepy,Twitter Streaming Api,我正在尝试使用Twitter流api收集带有一些坐标的过滤推文,以便映射它们。昨晚我收集推文时,流式api返回的Json对象中有一个坐标字段,今天我尝试做同样的事情,只是为了进一步过滤推文,只选择坐标不为null的推文。但我得到的每个Json对象都没有坐标字段。我搜索了谷歌和推特Api文档,但没有结果。问题是什么?我该如何处理 代码: 由于隐私原因,坐标字段默认不填充。用户必须在其配置文件中特别启用此地理定位功能。你没有看到它被使用的原因是很少有人启用它——只有不到1%的推特。place字段更常

我正在尝试使用Twitter流api收集带有一些坐标的过滤推文,以便映射它们。昨晚我收集推文时,流式api返回的Json对象中有一个坐标字段,今天我尝试做同样的事情,只是为了进一步过滤推文,只选择坐标不为null的推文。但我得到的每个Json对象都没有坐标字段。我搜索了谷歌和推特Api文档,但没有结果。问题是什么?我该如何处理

代码:


由于隐私原因,
坐标
字段默认不填充。用户必须在其配置文件中特别启用此地理定位功能。你没有看到它被使用的原因是很少有人启用它——只有不到1%的推特。
place
字段更常用。但是,它不会为您提供点位置。它有一个地名和一个边界框。

要检索坐标或位置(如果坐标为无),在所有包含“爱”一词的tweet中,我使用:

for tweet in tweepy.Cursor(api.search, q='love', count = 10).items():
    if (tweet.coordinates is not None):
        lon = tweet.coordinates['coordinates'][0]
        lat = tweet.coordinates['coordinates'][1]
     elif (tweet.place  is not None):
         # counding box of location
         bbox = tweet.place.bounding_box.coordinates
         lon = bbox[0][0][0]
         lat = bbox[0][0][1]
for tweet in tweepy.Cursor(api.search, q='love', count = 10).items():
    if (tweet.coordinates is not None):
        lon = tweet.coordinates['coordinates'][0]
        lat = tweet.coordinates['coordinates'][1]
     elif (tweet.place  is not None):
         # counding box of location
         bbox = tweet.place.bounding_box.coordinates
         lon = bbox[0][0][0]
         lat = bbox[0][0][1]