[英]Tweepy Streaming API returning “None” for coordinates on geo-enabled tweets
[英]Tweepy geo search keeps returning tweets far outside of range
請幫忙。 我正在嘗試使用免費的 tweepy API 完成特定於地理的查詢搜索。 我意識到返回的推文坐標/地點仍然來自全球各地,即使我簡化代碼進行調查:地理仍然無法工作:
# 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)
任何幫助將非常感激!
我認為您的地理參數被忽略了。 傳遞給搜索 api 的參數名稱是geocode
,而不是geo
。 嘗試這個:
results = api.search(q=query, geocode=gg, count=100)
當我以小至 10 公里的搜索半徑運行它時,我沒有得到任何結果。 如果我將半徑擴大到 1000 公里,我會得到更多。
參考: API.search
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.