gpt4 book ai didi

java - 无法获得 instagram 个人资料图片全尺寸

转载 作者:行者123 更新时间:2023-12-01 13:11:52 24 4
gpt4 key购买 nike

几天前,我能够通过从图片 URL 中删除 vp/并将分辨率从 更改为我的 android 应用程序中的 inta 个人资料图片。 s150x150 s720x720 对于 exp,它工作得很好,但现在我仍然得到“ 无效的 url 签名 ”,所以我认为 instagram 已经在他们的 url 中添加了签名,我通常在图片 URL 中删除从 vp/到/t51 的部分... 像这样

https://scontent-mxp1-1.cdninstagram.com/ 副总裁/xxxxxxxx /t51....jpg
但它不起作用!

我不知道 instagram 发生了什么,所以有人可以帮我找到解决这个问题的方法吗?或者另一种方法。谢谢

最佳答案

以下是截至 2020 年 5 月没有外部网站(如 https://www.instadp.com/)的操作方法.程序也可以使用这个 API 方法。

  • 首先,确保您已在要执行此操作的浏览器上登录 Instagram 帐户。
  • 在此 URL 中输入用户名代替“usernamehere”:

  • https://www.instagram.com/usernamehere/?__a=1


  • 访问网址。
  • 在开头复制“profilePage_”之后的数字。这是用户 ID。 (它也位于 JSON 中的 graphql.user.id 下。)
  • 粘贴此 URL 中的数字代替“numberhere”

  • https://i.instagram.com/api/v1/users/numberhere/info/


  • 访问网址。您很可能会看到 {"message": "useragent mismatch", "status": "fail"} .如果这样做,请执行以下步骤:
  • 如果您在 Chrome 中,请按 F12 或 Ctrl+Shift+I 或 Ctrl+Shift+J 打开 DevTools。
  • 在底部绘图中(您可以看到“控制台”、“新增功能”、网络条件),单击“网络条件”。
  • 在“用户代理”下,取消选中“自动选择”。
  • 选择“自定义...”,然后将 Instagram 移动用户代理粘贴到框中,如下所示:

  • Mozilla/5.0 (Linux; Android 9; GM1903 Build/PKQ1.190110.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36 Instagram 103.1.0.15.119 Android (28/9; 420dpi; 1080x2260; OnePlus; GM1903; OnePlus7; qcom; sv_SE; 164094539)


    您可以找到更多 here .
  • 不要关闭 DevTools。刷新页面。
    注:有browser extensions可以做到这一点。
    查看this tutorial了解如何在其他浏览器上执行此操作。
  • 按 Ctrl+F,然后搜索“hd_profile_pic_url_info”。
  • 复制“url”和“width”之间的 URL。很长,请仔细看。 (它位于 JSON 中的 user.hd_profile_pic_url_info.url 下。)

  • 注意:像 this one 这样的扩展名将使这部分变得容易得多。
  • 将 URL 粘贴到地址栏中,但不要按 Enter。
  • 在 URL 中查找“\u0026”的所有实例。在 URL 的后半部分应该有大约 3 个。这些是“&”的 JavaScript 代码,但它们在地址栏 URL 中不起作用(如果按 Enter,您将看到 Bad URL timestamp)。将它们全部替换为“&”。
  • 访问网址。

  • 现在您有了全分辨率的个人资料图片。 :)
    更新:终于开始编写一个函数来获取这个 URL。您可以在浏览器中使用它,而不必执行所有这些步骤。
    async function fetchIGProfilePic(input) {
    if (!/^https?:\/\/i.instagram.com\//.test(window.location.href)) {
    if (window.confirm('fetchIGProfilePic:\n\nWe need to navigate to i.instagram.com for the request to work. (We need to make the request from the same domain as the profile pic API; CORS policy.) Please run the script after doing this.\n\nNavigate to i.instagram.com? (Ignore the 404 error.)')) {
    window.location.href = 'https://i.instagram.com/api/v1/';
    return;
    } else {
    return 'fetchIGProfilePic: Cancelled.';
    }
    }
    let response;
    let output;
    try {
    response = await fetch('https://www.instagram.com/' + input + '/?__a=1');
    if (!response.ok) {
    console.log('Failed 1st step, to fetch userID, with bad response status:' + response.status);
    return;
    }
    } catch(error) {
    console.log('Failed 1st step, to fetch userID, with ok response status: ' + error);
    return;
    }
    let userData = await response.json();
    try {
    response = await fetch('https://i.instagram.com/api/v1/users/' + userData.graphql.user.id + '/info/', {
    // The following doesn't seem to be necessary in a console request, but I kept it in in case you have issues at this stage.
    headers: {'user-agent': 'Mozilla/5.0 (Linux; Android 9; GM1903 Build/PKQ1.190110.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36 Instagram 103.1.0.15.119 Android (28/9; 420dpi; 1080x2260; OnePlus; GM1903; OnePlus7; qcom; sv_SE; 164094539)'
    }
    });
    if (!response.ok) {
    console.log('Failed 2nd step, to fetch profile pic URL, with bad response status: ' + response.status);
    window.alert('fetchIGProfilePic:\n\nYou might not be logged in, which is necesary for the request to work. Please log into an Instagram account, then run this script again.');
    return;
    }
    } catch(error) {
    console.log('Failed 2nd step, to fetch profile pic URL, with ok response status: ' + error);
    return;
    }
    let profileData = await response.json();
    console.log('Full-size profile pic URL of ' + input + ':\n' + profileData.user.hd_profile_pic_url_info.url);
    }

    fetchIGProfilePic('instagram'); // Enter the username here.
    在浏览器中,按 F12 打开控制台,然后将脚本粘贴进去。将用户名放在底部括号中,然后按 Enter,它会在控制台中检索 URL。确保您在 https://i.instagram.com/api/v1/并在您运行脚本时登录 Instagram 帐户。

    关于java - 无法获得 instagram 个人资料图片全尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48662940/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com