2016-11-12 1 views
5

트윗을 가져 오는 다음 코드가 있습니다. 지정된 지오 코드는 뉴욕주의 지역입니다. 그러나 print (json_reply [ 'user'] [ 'location'])를 사용하여 위치를 인쇄하면 위치가 Voorburg, Netherlands로 인쇄됩니다. 프로필 정보에서 사용자가 지정한 위치라고 생각합니다. 또한 지오 코드는 항상 null을 반환합니다. 저는 뉴욕 주와 함께 Co-ordinates와 관련된 Tweets에 관심이 있습니다.Tweepy에서 좌표를 얻는 방법?

tweets = api.search(q='xyz', lang='en', since='2016-11-02',until='2016-11-06', geocode='43,-75,90km', count=1) 

json_str = json.dumps(tweets[0]._json) 
print(json_str) 
json_reply = json.loads(json_str) 
print(json_reply['text']) 
print(json_reply['created_at']) 
print(json_reply['user']['location']) 
print(json_reply['geo']) 

Voorburg의, 네덜란드

답변

2

당신은 실제로 tweepy의 검색 API를 사용하여이 작업을 수행 할 수 있습니다.

먼저

>>> places = api.geo_search(lat='43', long='-75', max_results=10) 
>>> places[0].id 
u'23e921b82040ccd6' 

그런 다음 place:<place_id>와 tweepy의 검색 API를 사용하여 ... place_id를 통해 얻을.

tweets = api.search(q='place:23e921b82040ccd6', count=100) 

참조 : https://dev.twitter.com/rest/public/search-by-place