Instagram Profile Picture in Full-Resolution?

早过忘川 提交于 2019-12-17 17:59:22

问题


how do I get the profile picture of an instagram profile in full-res? (The old URL scheme stopped working today).

regex='profile_pic_url_hd":"([0-9a-zA-Z._-/:]*)",'

Is working for 320px pictures, but nothing else. The prefix to the 150x150 img is different, but the ID/ending of the url with jpg is the same.

Thanks


回答1:


Okay guys I found a final solution:

  1. Get the user_id of the account using this link https://www.instagram.com/{name}/?__a=1

  2. Visit this JSON-API with the user_id above https://i.instagram.com/api/v1/users/{user_id}/info/ The full size profile picture link can be found in [hd_profile_pic_url_info][url]

Thats it! :)

[EDIT]

If step 1 doesn't work, my Php solution to get the user-id:

$name = "{username}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.instagram.com/$name/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($http=="200") {
  $doc = new DOMDocument();
  $doc->loadHTML($result);
  $xpath = new DOMXPath($doc);
  $js = $xpath->query('//body/script[@type="text/javascript"]')->item(0)->nodeValue;
  $start = strpos($js, '{');
  $end = strrpos($js, ';');
  $json = substr($js, $start, $end - $start);
  $data = json_decode($json, true);
  $user_id = $data["entry_data"]["ProfilePage"][0]["graphql"]["user"]["id"];
}

I'm searching in the HTML document for user-id.




回答2:


If you view the source html and run a simple find text search for logging_page_id, it will have profilePage_, then a number. That number is the user id.

e.g.:

logging_page_id":"profilePage_123456789

The user id is: 123456789




回答3:


It's not working anymore after update in Instagram api



来源:https://stackoverflow.com/questions/49458818/instagram-profile-picture-in-full-resolution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!