【问题标题】:I want to get the number of Instagram followers of a user with just id using JavaScript我想使用 JavaScript 获取只有 id 的用户的 Instagram 关注者数量
【发布时间】:2021-01-07 14:51:08
【问题描述】:

我想创建一个表单,如果用户添加他们的 Instagram id,则可以在没有“k”缩写的情况下获得关注者的绝对数量。但我不知道该怎么做。如果你知道请帮助我。如果您能发布代码将不胜感激...

【问题讨论】:

  • 到目前为止您尝试过什么?你被困在哪里了?如果您还没有开始,这个问题与 Wordpress 或 JSON 有什么关系?

标签: javascript php json wordpress instagram


【解决方案1】:

我认为您将能够处理表单创建和处理部分。如果没有,请阅读一些初级教程以获得一些想法。

关于关注者数量,您可以向该网址发出 GET 请求:

https://www.instagram.com/<username>/?__a=1

&lt;username&gt; 替换为用户的 Instagram 用户名。这将返回 JSON 数据。 您可以从该 JSON 对象中的graphql -&gt; user -&gt; edge_followed_by 访问关注者数量。

这是一个示例网址:https://www.instagram.com/akhileshbc/?__a=1

它是 JSON 数据:

{
    "logging_page_id": "profilePage_532689420",
    "show_suggested_profiles": false,
    "show_follow_dialog": false,
    "graphql": {
        "user": {
            "biography": "Simple, humble and quiet. \ud83e\udd37\u200d\u2642\ufe0f\n- Chaliyan \ud83e\udd2a\n- Loves driving \ud83d\ude97\n- Loves coding \ud83d\udcbb\nSookshich nokkendeda unnii.. Ithu njaan alla! \ud83d\ude01",
            "blocked_by_viewer": false,
            "restricted_by_viewer": null,
            "country_block": false,
            "external_url": "http://www.akhileshbc.com/",
            "external_url_linkshimmed": "https://l.instagram.com/?u=http%3A%2F%2Fwww.akhileshbc.com%2F&e=ATPlLqbGaXUR5wlxwYIjsDftFcWyvLfqAzAc3d6HlzF0-U3YZQF6veDJXH6zg8P1AZ8ZM-eaE0zJGZ18&s=1",
            "edge_followed_by": {
                "count": 516
            },
            "fbid": "17841400522608323",
            "followed_by_viewer": false,
            "edge_follow": {
                "count": 195
            },
            "follows_viewer": false,
            "full_name": "Akhilesh B Chandran",
            "has_ar_effects": false,
            "has_clips": false,
            "has_guides": false,
            "has_channel": false,
            "has_blocked_viewer": false,
            "highlight_reel_count": 0,
            "has_requested_viewer": false,
            "id": "532689420",
            "is_business_account": false,
            "is_joined_recently": false,
            "business_category_name": null,
            "overall_category_name": null,
            "category_enum": null,
            "category_name": null,
            "is_private": true,
            "is_verified": false,
            "edge_mutual_followed_by": {
                "count": 0,
                "edges": []
            },
            "profile_pic_url": "https://instagram.ftrv1-1.fna.fbcdn.net/v/t51.2885-19/s150x150/53646757_406084366897615_5102538752442499072_n.jpg?_nc_ht=instagram.ftrv1-1.fna.fbcdn.net&_nc_ohc=hRS4KKbebn4AX-ZnN7t&tp=1&oh=8e2899b2638452829998bf7e6e451df1&oe=601F3EB5",
            "profile_pic_url_hd": "https://instagram.ftrv1-1.fna.fbcdn.net/v/t51.2885-19/s320x320/53646757_406084366897615_5102538752442499072_n.jpg?_nc_ht=instagram.ftrv1-1.fna.fbcdn.net&_nc_ohc=hRS4KKbebn4AX-ZnN7t&tp=1&oh=a12a5d28edda0906ed2e318e75d47392&oe=6020E3C5",
            "requested_by_viewer": false,
            "should_show_category": false,
            "username": "akhileshbc",
            "connected_fb_page": null,
            "edge_felix_video_timeline": {
                "count": 0,
                "page_info": {
                    "has_next_page": false,
                    "end_cursor": null
                },
                "edges": []
            },
            "edge_owner_to_timeline_media": {
                "count": 47,
                "page_info": {
                    "has_next_page": false,
                    "end_cursor": null
                },
                "edges": []
            },
            "edge_saved_media": {
                "count": 0,
                "page_info": {
                    "has_next_page": false,
                    "end_cursor": null
                },
                "edges": []
            },
            "edge_media_collections": {
                "count": 0,
                "page_info": {
                    "has_next_page": false,
                    "end_cursor": null
                },
                "edges": []
            },
            "edge_related_profiles": {
                "edges": []
            }
        }
    },
    "toast_content_on_load": null,
    "show_view_shop": false,
    "profile_pic_edit_sync_props": null
}

这里的 516 是我的粉丝数。

【讨论】:

    【解决方案2】:

    好吧,我想唯一的方法是获取该用户的 HTML 页面并搜索该信息。 我建议在云端创建一个API,这样你就可以随着网站HTML的变化快速改变机制。

    问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 2019-07-11
      相关资源
      最近更新 更多