【问题标题】:Twitter API: How to search only for geotagged tweetsTwitter API:如何仅搜索带有地理标记的推文
【发布时间】:2011-05-19 05:58:55
【问题描述】:

如何使用Twitter Search API(或其他)来获取具有"geo" 参数的推文列表?

--编辑--

例如:我不会通过#apple 标签获取带有地理标签的推文列表。没有位置过滤器,全球。

【问题讨论】:

  • 我想要完全一样的。你设法让它工作吗?
  • Twitter 搜索 API 和地理参数不会像您预期的那样工作,它仍然可以返回没有提供坐标的结果(没有纬度/经度)。

标签: api search twitter


【解决方案1】:

看起来最新的 API 支持它;只需为您的查询使用足够大的地理区域:

-180,-90,180,90

通过filter and location 的 API 链接查看更多信息

【讨论】:

    【解决方案2】:

    流式 API 允许您按位置过滤,搜索 API 允许您按地理编码进行搜索。您可以在我们的开发者资源网站上找到有关这些服务的更多信息。

    流媒体 API:http://dev.twitter.com/pages/streaming_api

    示例:创建一个名为“locations”的文件 包含,不包括引用 标记,短语: “locations=-122.75,36.8,-121.75,37.8,-74,40,-73,41” 然后执行:

    curl -d @locations http://stream.twitter.com/1/statuses/filter.json -uAnyTwitterUser:密码。

    您将收到所有带有地理标签的推文 来自旧金山和纽约 市区。

    搜索接口:http://dev.twitter.com/doc/get/search

    示例:http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi

    【讨论】:

    • 我读过这个,问题是我不想限制位置,但只接收带有地理标记的推文。
    • 目前的 twitter api 无法做到这一点。您要问的是 twitter 为您提供某种过滤的提要 - 为什么 twitter 会浪费带宽和服务器时间来预过滤提要?您将不得不下载所有提要,自己过滤它们,在半径内搜索提要或类似的东西 - 这取决于您进行过滤。
    • “您要求的是 twitter 为您提供某种过滤的提要”...如果我使用参数 geocode=37.781157,-122.398720,1mi 进行搜索,如您的示例所示,那也是“过滤提要”,只要请求仅带有地理标记的推文是“过滤提要”。很好,目前没有办法做到这一点,感谢您的说明,但提供该功能不会比现有的地理标签过滤器浪费更多的服务器时间,而且它会消耗更少的带宽,因为我们不必在何时拉下所有推文我们只想要一个子集。
    • 我也遇到了同样的问题,经过一番谷歌搜索,我总结了方法here。希望这可以在以后对其他人有所帮助。
    • @YanzheChen 你这边目前处于关闭状态。如果您有信息,我会对这种方法感兴趣。谢谢
    【解决方案3】:

    来自Twitter API 文档,这应该是您的搜索查询的格式:

     http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
    

    37.781157 是纬度,-122.398720 是经度,1mi 是要搜索的半径。

    【讨论】:

    • 那么指定 10000000miles 会覆盖整个地球并回答 OP 的问题吗?这行得通吗?
    • # geocode Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.
    • 此请求返回任何带有“geo”或不带“geo”的推特。我只需要在 JSON 中使用“geo”参数获取 twitts。
    • 这是一个非常缓慢的解决方案,但似乎没有其他方法
    • 是的,我尝试搜索来自世界各地的带有地理标签的推文。
    【解决方案4】:

    您可以查找每条推文,但只保存带有地理标记的推文。 我知道它没有多大意义,但效果很好。

    如果你叫你搜索结果,你可以声明

    for result in results:
        if result.geo != None:
            print result.text.encode('utf-8', errors='ignore')  # or do anything you want with the tweets
    

    【讨论】:

      【解决方案5】:

      使用-180,-90,180,90 获取任何带有地理标记的推文。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-10
      • 2012-09-26
      • 2018-03-12
      • 1970-01-01
      • 2014-01-12
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      相关资源
      最近更新 更多