小编Sos*_*ame的帖子

使用Tweepy从Twitter获取特定位置的推文

我正在尝试使用Tweepy从特定位置获取推文,但是当我运行代码时出现此错误

raise TweepError("Wrong number of locations points, "
tweepy.error.TweepError: Wrong number of locations points, it has to be a multiple of 4
Run Code Online (Sandbox Code Playgroud)

在我的代码中,我尝试使用NY的位置坐标从纽约市获取推文.我怎样才能从纽约单独得到推文?我的猜测是在x,y和y,z之间使用一系列坐标.我该怎么做?

这是我的代码:

class StdOutListener(StreamListener):
    """ A listener handles tweets are the received from the stream.
    This is a basic listener that just prints received tweets to stdout.
    """
    def on_data(self, data):
        try:
            print(data)
            saveFile = open('newtweets.csv', 'a')
            saveFile.write(data)
            saveFile.write('/n').encode("utf-8")
            saveFile.close()
            return True
        except BaseException:
            print ('failed ondata')
            time.sleep(5)

    def on_error(self, status):
        print(status.encode("utf-8"))

if __name__ == '__main__':
    l = …
Run Code Online (Sandbox Code Playgroud)

python twitter geolocation tweepy tweetstream

6
推荐指数
1
解决办法
3041
查看次数

标签 统计

geolocation ×1

python ×1

tweepy ×1

tweetstream ×1

twitter ×1