位置过滤器扭曲模块

时间:2018-12-13 21:38:41

标签: location coordinates tweepy

嗨,我只想从巴西获得推文。这是我的代码,但是我想知道是否有一种方法可以使位置更加紧密,以使其不包括邻国(即该区域的形状不是正方形,而是正方形)。

class CustomStreamListener(tweepy.StreamListener):
    def on_data(self, data):
        try:
            with open('brasil.json', 'a') as f:
                f.write(data)
                return True
    except BaseException as e:
        print("Error on_data: %s" % str(e))
    return True

def on_error(self, status_code):
    print >> sys.stderr, 'Encountered error with status code:', status_code
    return True # Don't kill the stream

def on_timeout(self):
    print >> sys.stderr, 'Timeout...'
    return True # Don't kill the stream

sapi = tweepy.streaming.Stream(auth, CustomStreamListener())    
sapi.filter(locations=[-74.1,-34.3,-34.1,5.6])

1 个答案:

答案 0 :(得分:0)