Tweepy 全存档搜索、Twitter 高级搜索和 GetOldTweets3 返回不同数量的推文
Tweepy full-archive search, Twitter Advanced Search, and GetOldTweets3 are returning different numbers of Tweets
使用带有以下参数的 Tweepy、GetOldTweets3 和 Twitter 高级搜索时:
- 查询:"Accident"
- 地点:"Dallas, TX"
- 开始于:“2018/1/1”
- 直到:“2018/1/2”
每种搜索方法的推文数量都不同。 Tweepy,使用全存档搜索,returns 12 条推文。 GetOldTweets3 returns 22 条推文。并使用 Twitter 高级搜索 returns 3 条推文。不同数量的推文是否有原因?
Twitter 通过其网站进行的搜索使用的运算符与其 API 不同。
Searching "Accident near:Dallas,TX since:2018-01-01 until:2018-01-02" on Twitter itself,产生 22 条推文。如果您只查看最热门的,那么只有 3 个,是的,但是您可以通过单击“最新”选项卡查看所有这些。此查询使用的 near
运算符似乎没有在任何地方明确记录,因此不清楚它究竟是如何工作的。事实上,location/place 甚至似乎不再是高级搜索 UI 的一部分。从历史上看,这似乎是通过在指定位置的半径(如果未设置 within
运算符则默认为 15 英里)内搜索来实现的。
当前分支/PR for Tweepy adding API.search_full_archive
, which is what I assume you're using, uses the full-archive endpoint of Twitter's premium search APIs. Something like api.search_full_archive("Environment_Name", "Accident place:Dallas,TX", fromDate=201801010000, toDate=201801020000)
does in fact return 12 Tweets. However, this is using the documented place
premium search operator,具有特定定义的行为:
Matches Tweets tagged with the specified location or Twitter place ID
这意味着它只会 return 专门标记有该位置的推文,而不包括特定半径内附近的其他位置。奇怪的是,这些结果实际上包括网站搜索遗漏的 2 条推文,而且位置搜索似乎 return 也没有。这可能是由于 Twitter's search policies,但同样,很难确定确切的原因,因为 Twitter 的网站搜索没有记录并且有点像黑匣子。
如果您想使用高级搜索 API 为您的搜索指定一组坐标和半径,您可以使用 point_radius
高级搜索运算符。使用代表德克萨斯州达拉斯的 Tweepy API.geo_search
method, which uses the Twitter API's GET geo/search endpoint, and a query for "Dallas,TX", the Place object returned 指定 [-96.7301749064317, 32.819858499999995]
的质心。不能保证这些是 Twitter 网站搜索使用的坐标,但通过一些测试,将这些坐标与 point_radius
一起使用,return 与网站搜索结果匹配的确切结果的半径似乎在某处在 17 到 18 英里之间。半径为 17.5 英里,只有 3 条来自普莱诺的额外推文。
GetOldTweets3 不使用 Twitter 的 API,而是直接抓取网站。这不应该被认为是可靠的并且反对 Twitter's Terms of Service:
scraping the Services without the prior consent of Twitter is expressly prohibited
如果您想要最准确和明确的结果,您应该使用 Twitter 的 API。如果您想在不违反 Twitter 服务条款的情况下以编程方式检索这些结果,这是唯一有效的方法。您的位置搜索选项是通过名称或 Twitter 地点 ID、坐标和半径或边界框专门针对该位置,使用 place
、point_radius
或 bounding_box
高级搜索运营商,分别。请注意,由于某些原因,如其他 2 条推文所示,某些推文可能只能通过特定位置而不是区域找到。
使用带有以下参数的 Tweepy、GetOldTweets3 和 Twitter 高级搜索时:
- 查询:"Accident"
- 地点:"Dallas, TX"
- 开始于:“2018/1/1”
- 直到:“2018/1/2”
每种搜索方法的推文数量都不同。 Tweepy,使用全存档搜索,returns 12 条推文。 GetOldTweets3 returns 22 条推文。并使用 Twitter 高级搜索 returns 3 条推文。不同数量的推文是否有原因?
Twitter 通过其网站进行的搜索使用的运算符与其 API 不同。
Searching "Accident near:Dallas,TX since:2018-01-01 until:2018-01-02" on Twitter itself,产生 22 条推文。如果您只查看最热门的,那么只有 3 个,是的,但是您可以通过单击“最新”选项卡查看所有这些。此查询使用的 near
运算符似乎没有在任何地方明确记录,因此不清楚它究竟是如何工作的。事实上,location/place 甚至似乎不再是高级搜索 UI 的一部分。从历史上看,这似乎是通过在指定位置的半径(如果未设置 within
运算符则默认为 15 英里)内搜索来实现的。
当前分支/PR for Tweepy adding API.search_full_archive
, which is what I assume you're using, uses the full-archive endpoint of Twitter's premium search APIs. Something like api.search_full_archive("Environment_Name", "Accident place:Dallas,TX", fromDate=201801010000, toDate=201801020000)
does in fact return 12 Tweets. However, this is using the documented place
premium search operator,具有特定定义的行为:
Matches Tweets tagged with the specified location or Twitter place ID
这意味着它只会 return 专门标记有该位置的推文,而不包括特定半径内附近的其他位置。奇怪的是,这些结果实际上包括网站搜索遗漏的 2 条推文,而且位置搜索似乎 return 也没有。这可能是由于 Twitter's search policies,但同样,很难确定确切的原因,因为 Twitter 的网站搜索没有记录并且有点像黑匣子。
如果您想使用高级搜索 API 为您的搜索指定一组坐标和半径,您可以使用 point_radius
高级搜索运算符。使用代表德克萨斯州达拉斯的 Tweepy API.geo_search
method, which uses the Twitter API's GET geo/search endpoint, and a query for "Dallas,TX", the Place object returned 指定 [-96.7301749064317, 32.819858499999995]
的质心。不能保证这些是 Twitter 网站搜索使用的坐标,但通过一些测试,将这些坐标与 point_radius
一起使用,return 与网站搜索结果匹配的确切结果的半径似乎在某处在 17 到 18 英里之间。半径为 17.5 英里,只有 3 条来自普莱诺的额外推文。
GetOldTweets3 不使用 Twitter 的 API,而是直接抓取网站。这不应该被认为是可靠的并且反对 Twitter's Terms of Service:
scraping the Services without the prior consent of Twitter is expressly prohibited
如果您想要最准确和明确的结果,您应该使用 Twitter 的 API。如果您想在不违反 Twitter 服务条款的情况下以编程方式检索这些结果,这是唯一有效的方法。您的位置搜索选项是通过名称或 Twitter 地点 ID、坐标和半径或边界框专门针对该位置,使用 place
、point_radius
或 bounding_box
高级搜索运营商,分别。请注意,由于某些原因,如其他 2 条推文所示,某些推文可能只能通过特定位置而不是区域找到。