Last active
August 29, 2015 14:20
-
-
Save sue445/581ef004bc86817729ac to your computer and use it in GitHub Desktop.
instagramからLike数の多いのを抽出するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Chromeのwebインスペクタに下記を入力して実行 | |
var images = []; | |
$(".PhotoGridMediaItem").each(function(){ | |
// ex. いいね!7件・コメント0件 | |
var label = $(this).attr("aria-label"); | |
var url = "https://instagram.com" + $(this).find(".pgmiImageLink").attr("href"); | |
images.push({label: label, url: url}); | |
}); | |
// labelで降順ソート | |
images.sort(function(a, b){ | |
if(a.label > b.label){ | |
return -1; | |
} else if(a.label < b.label){ | |
return 1; | |
} | |
return 0; | |
}); | |
// 多い順に3件くらい表示 | |
for(i = 0; i < 3; i++){ | |
console.log(images[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment