Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 仅限制地理标记的推文通过mongodb_Python_Mongodb_Twitter_Pymongo_Tweetstream - Fatal编程技术网

Python 仅限制地理标记的推文通过mongodb

Python 仅限制地理标记的推文通过mongodb,python,mongodb,twitter,pymongo,tweetstream,Python,Mongodb,Twitter,Pymongo,Tweetstream,我目前正在使用在MongoDB中存储推文。 我已经设置了一个使用python 2.7运行的脚本: extent =["144.715, -38.03", "145.219, -37.541"] with tweetstream.FilterStream(username, password, locations=extent) as stream: for tweet in stream: db.tweets.save(tweet) 这很好,可以将推文存储到mongo

我目前正在使用在MongoDB中存储推文。
我已经设置了一个使用python 2.7运行的脚本:

extent =["144.715, -38.03", "145.219, -37.541"]

with tweetstream.FilterStream(username, password, locations=extent) as stream:
    for tweet in stream:
        db.tweets.save(tweet)
这很好,可以将推文存储到mongoDb中,但也可以存储没有地理位置的推文。也就是说,空白的也被存储。

对我来说,当前脚本应该只将指定范围内的tweet保存到我的mongoDb中,但这不会发生


有人能建议如何修改我的脚本,以便只捕获在我指定的
范围内向mongoDb发送带地理标记的推文吗?

推特支持两种不同级别的地理位置准确性,允许用户限制他们共享的信息

为什么我能看到一些推文的确切位置,而只看到一般位置 附近(社区或城市)是否有其他人?

默认显示为地点位置(如邻居或城镇),但 一些第三方应用程序可以让你在推特上显示你的确切位置或位置 地址。如果您通过 第三方应用程序,实际坐标可以公开共享

tweetstream.FilterStream返回的推文可以是任意一种精度。一些tweet只具有位置级别的准确性,在这种情况下,“坐标”键将为无

 u'coordinates': None,
 u'place': {u'attributes': {},
            u'bounding_box': {u'coordinates': [[[-122.51368188,
                                                 37.70813196],
                                                [-122.35845384,
                                                 37.70813196],
                                                [-122.35845384,
                                                 37.83245301],
                                                [-122.51368188,
                                                 37.83245301]]],
                              u'type': u'Polygon'},
            u'country': u'United States',
            u'country_code': u'US',
            u'full_name': u'San Francisco, CA',
            u'id': u'5a110d312052166f',
            u'name': u'San Francisco',
            u'place_type': u'city',
            u'url': u'http://api.twitter.com/1/geo/id/5a110d312052166f.json'},
其他tweet将有一个准确的位置,在这种情况下,将填充“坐标”键:

 u'coordinates': {u'type': 'Point', u'coordinates': [-122.51368188, 37.83245301]}

您需要决定是否对位置级别的准确度推文感兴趣。如果是,您可以将其坐标存储为多边形,也可以计算质心。

Twitter支持两种不同级别的地理定位精度,允许用户限制他们共享的信息

为什么我能看到一些推文的确切位置,而只看到一般位置 附近(社区或城市)是否有其他人?

默认显示为地点位置(如邻居或城镇),但 一些第三方应用程序可以让你在推特上显示你的确切位置或位置 地址。如果您通过 第三方应用程序,实际坐标可以公开共享

tweetstream.FilterStream返回的推文可以是任意一种精度。一些tweet只具有位置级别的准确性,在这种情况下,“坐标”键将为无

 u'coordinates': None,
 u'place': {u'attributes': {},
            u'bounding_box': {u'coordinates': [[[-122.51368188,
                                                 37.70813196],
                                                [-122.35845384,
                                                 37.70813196],
                                                [-122.35845384,
                                                 37.83245301],
                                                [-122.51368188,
                                                 37.83245301]]],
                              u'type': u'Polygon'},
            u'country': u'United States',
            u'country_code': u'US',
            u'full_name': u'San Francisco, CA',
            u'id': u'5a110d312052166f',
            u'name': u'San Francisco',
            u'place_type': u'city',
            u'url': u'http://api.twitter.com/1/geo/id/5a110d312052166f.json'},
其他tweet将有一个准确的位置,在这种情况下,将填充“坐标”键:

 u'coordinates': {u'type': 'Point', u'coordinates': [-122.51368188, 37.83245301]}

您需要决定是否对位置级别的准确度推文感兴趣。如果是,您可以将其坐标存储为多边形,或者计算质心。

您不能使用类似于
If tweet['coordinates']:db.tweets.save(tweet)
的东西吗?如果tweet['coordinates']:db.tweets.save(tweet)
您不能使用类似于
If tweet['coordinates']:db.tweet.save(tweet)