在没有api的情况下将Instagram hashtag json获取到Google表格的问题 [英] Problem with getting Instagram hashtag json without api into google sheets

查看:77
本文介绍了在没有api的情况下将Instagram hashtag json获取到Google表格的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将#tag JSON从Instagram返回到Google表格.如果将URL放在浏览器中但不使用googlesheet脚本(过去曾经使用过),我会得到JSON.

I'm trying to get a hashtag JSON back from Instagram to google sheets. I get the JSON if I put the URL in a browser but not using google sheets script (it used to work in the past).

这是我的代码:

//Trying to bring back json from instagram
  var tag = 'trivia';
  var url = "https://www.instagram.com/explore/tags/"+tag+"/?__a=1";
  var response = UrlFetchApp.fetch(url).getContentText();
  Logger.log(response);

我明白了:

[20-06-21 12:01:29:962 IDT] <!DOCTYPE html>
<html lang="en" class="no-js not-logged-in client-root">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <title>
Login • Instagram
</title>...

代替此操作(当我在浏览器中放置相同的URL时- https://www.instagram.com/explore/tags/trivia/?__a=1 ):这实际上是我实际上需要在Google表格中获取的内容.

instead of this (when I put the same url in a browser- https://www.instagram.com/explore/tags/trivia/?__a=1): which is what I actually need btw to get in google sheets.

{"graphql":{"hashtag":{"id":"17841563248119719","name":"trivia","allow_following":true,"is_following":false,"is_top_media_only":false,"profile_pic_url":"https://instagram.fsdv3-1.fna.fbcdn.net/v/t51.2885-15/e15/s150x150/103649320_140557634281171_6362475220936910641_n.jpg?_nc_ht=instagram.fsdv3-1.fna.fbcdn.net&_nc_cat=107&_nc_ohc=QVtIBqOksWoAX9m12su&oh=fcaa18b44873d0b30d46e6c3369535c1&oe=5F1930BA","edge_hashtag_to_media":{"count":1284222,"page_info":{"has_next_page":true,"end_cursor":"QVFBdkxFeVcxRkFtVjVPaWdNZDhQeHRobHo0dlVfdjhtekVwazRTcjBIOXlwb0NqRndwaDZPZ195ZFdRd2t5RjU1OThiVExXLV9iLU5YUlkwSk5BUmE2LQ=="},"edges":[{"node":{"comments_disabled":false,"__typename":"GraphSidecar","id":"2336312505423207882","edge_media_to_caption":{"edges":[{"node":{"text":"Information about the movie:\n1. Director:\u00a0James Cameron\n2. Box office:\u00a0279 crores\u00a0\n3. Budget:\u00a023.7 crores\u00a0\n4. Film series:\u00a0Avatar Series\n5. IMDB: 7.8/10\n#avatar\u00a0#no.1movie\u00a0#jamescameron\u00a0#trivia\u00a0#facts#didyouknow\u00a0#information\u00a0#actors\u00a0#like\u00a0#follow#horrormovies\u00a0#fashion\u00a0#instamovies\u00a0#entertainment#moviereview\u00a0#bluray\u00a0#series\u00a0#photooftheday\u00a0#dvd\u00a0#bhfyp#marvel\u00a0#moviestar\u00a0#acting\u00a0#action\u00a0#movietime\u00a0#filmes#peliculas\u00a0#theatre\u00a0#oscars\u00a0#moviequotes"}}]},"shortcode":"CBsP9hqDZ3K","edge_media_to_comment":{"count":0},"taken_at_timestamp":1592730175,"dimensions":{"height":1080,"width":1080},"display_url":"https://instagram.fsdv3-1.fna.fbcdn.net/v/t51.2885-15/e35/104434100_280716426462541_3340933663299493770_n.jpg?_nc_ht=instagram.fsdv3-1.fna.fbcdn.net&_nc_cat=101&_nc_ohc=wYDWOpszIK0AX8sTi3N&oh=980538cb2e588f4467f0769ebae0c30e&oe=5F187460","edge_liked_by":{"count":6},"edge_media_preview_like":{"count":6},"owner":{"id":"37570480318"},"thumbnail_src":"https://instagram.fsdv3-1.fna.fbcdn.net/v/t51.2885-15/sh0.08/e35/s640x640/104434100_280716426462541_3340933663299493770_n.jpg?_nc_ht=instagram.fsdv3-1.fna.fbcdn.net&_nc_cat=101&_nc_ohc=wYDWOpszIK0AX8sTi3N&oh=97756e538cc662343493f9c6588fdfe2&oe=5F17CA66","thumbnail_resources":[{"src":"https://instagram.fsdv3-1.fna.

请帮助,请不要建议获得一个噩梦般的api-无论如何,我不需要那么多查询

please help and please don't suggest getting an api which is a nightmare - I don't need that many queries anyway

推荐答案

您正在使用两件事.

  1. 浏览器
  2. 是Google表格脚本.

出现错误的原因是Instagram僵尸程序,它在向您发出请求时实际上会跟踪您的IP.登录浏览器并请求此https://www.instagram.com/explore/tags/"+tag+"/?__a=1时,您将始终获得数据而不会被阻止.

The reason why you are getting error is Instagram bot which actually tracks your IP when you make a request to it. When you are logged into your browser and request this https://www.instagram.com/explore/tags/"+tag+"/?__a=1 then you will always get data without being blocked.

但是现在,在淘汰旧的Instagram开发人员工具之后,端点的速率限制已降至每小时200个.您被封锁是因为您超过了限制,Instagram机器人花了一些时间再次重置您的限制.

But now, after the deprecation of old Instagram developer tool the rate limit of endpoints have reduced to 200 per hour. You get blocked because you cross the limit and Instagram bot takes time to reset your limit again.

这可能需要2-3天或更长时间,具体取决于被阻止的频率. 解决方案是,如果您正确地将会话和cookie应用于请求标头,那么它一定会对您有所帮助.

It may take 2-3 days or more depending on frequency of getting blocked. Yhe solution is if you properly apply session and cookies to request headers then it will surely help you.

这篇关于在没有api的情况下将Instagram hashtag json获取到Google表格的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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