如何获得最受欢迎的标签?

编程入门 行业动态 更新时间:2024-10-22 16:20:46
本文介绍了如何获得最受欢迎的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何从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:

  • api.instagram/v1/tags/search ?q = a

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

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

  • api.instagram/v1/tags/search ?q = aa

然后,您将获得以"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.

更多推荐

如何获得最受欢迎的标签?

本文发布于:2023-11-25 15:38:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630332.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最受欢迎   如何获得   标签

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!