IG再網頁執行時透過js取得到JSON格式的資料
程式碼如下:
$.ajax({
url: 'https://www.instagram.com/cristiano/',
success: function (response) {
var p = $.parseHTML(response, true);
var v = JSON.parse($(p).filter('script')[4].innerHTML.replace('window._sharedData =', '').replace(';', '')).entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges;
for (var i = 0; i < 6; i++) {
var node = v[i].node;
var image = node.display_url;
var shortUrl = node.shortcode;
console.log(image);
}
}
});