简体   繁体   English

带有地理编码的 Twitter 搜索 api 几乎不返回任何命中

[英]Twitter search api with geocode hardly returns any hits

My request only returns twenty or so hits.我的请求只返回二十个左右的点击。 Notice I set the radius to be 5000km which is ridiculous, that's because I used 50 first but got too few hits, so I increased it.请注意,我将半径设置为 5000 公里,这很荒谬,这是因为我先使用了 50,但命中率太低,所以我增加了它。 But even at 5000km, I'm still getting the same few results.但即使在 5000 公里处,我仍然得到相同的结果。 I'm using Python 3.5 .我正在使用Python 3.5

Here is the code:这是代码:

import tweepy

consumer_key = 'xxxxx'
consumer_secret = 'xxxxxxxxx'
access_token = 'xxxxxxx'
access_token_secret = 'xxxxxxxxxxxxxxx'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)
results = api.search(q="Global Warming",geocode="40.7142700,-74.0059,5000km",count=100)
for result in results:
    print (result.text.encode('utf-8'))

Twitter limits how far back in the past you can search to about one week. Twitter 将您可以搜索的时间限制在一周左右。 You have reached that limit.您已达到该限制。 You can see this for yourself if you inspect the created_at field of the last tweet returned.如果您检查返回的最后一条推文的created_at字段,您可以亲眼看到这一点。

You are probably missing on tweets which:您可能错过了以下推文:

  • Lack location缺乏位置
  • Located outside of 1,000 distinct “sub-regions” from given location位于给定位置的 1,000 个不同“子区域”之外

When searching on tweets with the geocode field, the API will first search for tweets with geolocation specified, otherwise it will use the location from the user profile.在使用geocode字段搜索推文时, API将首先搜索具有指定地理位置的推文,否则将使用用户个人资料中的位置。

From the Search API on Geolocalization :从关于GeolocalizationSearch API

Geolocalization : The search operator “near” isn't available in API, but there is a more precise way to restrict your query by a given location using the geocode parameter specified with the template “latitude,longitude,radius”, for example, “37.781157,-122.398720,1mi”. Geolocalization:搜索运算符“附近”是不是在API可用,但有一个给定的位置使用与模板“纬度,经度,半径”所指定的地理编码参数,例如,限制你的查询更精确的方式,“ 37.781157,-122.398720,1mi”。 When conducting geo searches, the search API will first attempt to find tweets which have lat/long within the queried geocode, and in case of not having success, it will attempt to find tweets created by users whose profile location can be reverse geocoded into a lat/long within the queried geocode, meaning that is possible to receive tweets which do not include lat/long information.在进行地理搜索时,搜索 API 将首先尝试查找在所查询的地理编码中具有经纬度的推文,如果没有成功,它将尝试查找由其个人资料位置可以被反向地理编码为查询地理编码中的纬度/经度,这意味着可以接收不包含纬度/经度信息的推文。

From the search/tweets doc:search/tweets文档:

A maximum of 1,000 distinct “sub-regions” will be considered when using the radius modifier.使用半径修改器时将考虑最多 1,000 个不同的“子区域”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM