在 Python 包中收集 Twitter 的坐标



我尝试从推特上收集带有坐标的数据。但是,我得到的结果是'coordinates: None'

from twitter import *
from email.utils import parsedate
stream = TwitterStream(auth = auth, secure = True)
stream
search_term = "candy"
tweet_stream = stream.statuses.filter(track = search_term, language='en',    geo=True) 
l =[]
for tweet in tweet_stream:
l.append(tweet)

我们是否有从推特收集地理数据的参数?还是取决于有权访问该位置的用户?

一些用户有意分享他们的位置。 我听说大约 1%。由于隐私权,默认情况下无法设置。

你可以得到这样的坐标:

if tweet.coordinates is not None:
#print(tweet.coordinates) # => {'type': 'Point', 'coordinates': [2.28892949, 48.85200032]}
lon = tweet.coordinates['coordinates'][0]
lat = tweet.coordinates['coordinates'][1]

最新更新