Twitter 流媒体位置 [英] Twitter streaming by locations

查看:40
本文介绍了Twitter 流媒体位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 tweepy 来流式传输按位置坐标过滤的推文.目前,我一直在从一个城市的两个不同社区流式传输推文,发现尽管坐标不同(它们是不重叠的区域),但推文是相同的.

I use tweepy to stream tweets filtered by location coordinates. Currently I've been streaming tweets from two different neighborhoods in a city and found out that the tweets are the same despite difference in the coordinates (they are non-overlapping areas).

是否有推特 API 可以过滤推文的坐标分辨率?

Is there a resolution of the coordinates up to which the twitter API can filter the tweets?

以下是主播的示例代码:

Here's a sample code for a streamer:

(带有示例位置的代码)

(Code with sample locations)

import handler
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from tweepy import API

ckey = 'blahblah..'
csecret = 'blah blah...'
atoken = 'blah blah...'
asecret = 'blah blah...'


Loc1 = [-70.981963,41.591322,-70.89941601,41.75938768]                
Loc2 = [-70.919537579,41.608616525,-70.905971579,41.617116525]      
Loc3 = [-70.92909611,41.621725545,-70.92084611,41.632153545]     


class listener(StreamListener):

    def on_status(self, status ):
        try:
            x = handler.editor('file.csv', status)        #used to save some data to file
            print x.encode("utf-8")
            return True

        except BaseException, e:
            print 'Exception:, ',str(e)

    def on_error(self, status):
        print status

auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth,listener())
twitterStream.filter(locations = Loc1)

我使用不同的授权详细信息和位置运行此代码的多个实例.在这种情况下,Loc2 和 Loc3 是 Loc1 中的邻域.

I run several instances of this code with different authorization details and locations. In this case Loc2 and Loc3 are neighborhoods in Loc1.

推荐答案

我认为分辨率以 0.1 度为增量.https://dev.twitter.com/docs/api/1.1/post/状态/过滤器

I think the resolution is in increments of 0.1 degree. https://dev.twitter.com/docs/api/1.1/post/statuses/filter

您必须获取该地区的所有推文,并自行过滤那些有坐标的推文.

You will have to take all tweets of the region and filter by yourself for those that have the coordenades.

这篇关于Twitter 流媒体位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆