如何获得最受欢迎的标签? [英] How do I get the most popular tags?

查看:60
本文介绍了如何获得最受欢迎的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Instagram API获得最受欢迎的标签?我搜索了API,但没有找到检索此数据的方法. 该网站可以获取它,但是如何?

How do I get the most popular tags from Instagram API? I searched the API, but didn't find a way to retrieve this data. This website gets it, but how?

推荐答案

这个问题很旧,但对于其他人来说,也遇到了同样的问题,正如塞巴斯蒂安(Sebastien)提到的那样,没有这样的查询.但是,我最近一直需要相同的功能,并且想到了小遍历几乎可以解决问题的想法.

The question is old, but for others also struggling the same problem, as Sebastien mentioned there is no such query. However I have been recently needing same functionality and came down idea that small traversal pretty much solves the problem.

Instagram不会回复您仅以一个字母开头的标签列表. 示例:

Instagram doesn't respond you a list of tags starting with just one letter. Example:

此URL仅返回一个元素,即"a".但是,如果您发送的请求包含两个字符,例如

This URL returns just one element, which is "a". However if you send a request containing two characters like

然后,您将获得以"aa"开头的最受欢迎的标签

then you'll end up with the most popular tags starting on "aa"

此后,您只需在O(N ^ 2)时间内遍历您想要的字母,然后通过加入响应就可以得到最受欢迎标签的列表.

Afterwards you can simply traverse your desired alphabet in O(N^2) time and by joining responses you'll end up with a list of most popular tags.

英语(拉丁)字母的长度为26 ^ 2 = 676 尽管您不应该尝试获取更多标签,因为限制仍然是5,000个请求,而 17576 会花费26 ^ 3.

Length in case of English(Latin) alphabet would be 26^2 = 676 Though you shouldn't probably try getting any more tags as the limit is still 5,000 requests and 26^3 would go for 17576.

foreach(character in 'a'...'
{
   foreach(character in 'a'...'z')
   {
       Send hashtag request 'aa'...'az'...'zz'
       Get json and merge with previous array
   }
}

Sort final array by [media_count]

另一种方法是解析一些巨大的字典(例如Wikipedia dump),并筛选出5000个最常见的前缀,然后尝试查询它们.

Alternate approach would be to parse some huge dictionary (wikipedia dump for example) and sort out top 5000 most common prefixes and try querying them.

这篇关于如何获得最受欢迎的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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