const fetch = require("node-fetch"); const fs = require("fs"); // hoang.yennn_ : 6958719470 // trahaly_0109 : 11465783234 // box.girl.vn : 32557564687 (async () => { const cookie = "ig_did=A9E89E74-311D-4BB2-8762-2735425D6E4A; ig_nrcb=1; mid=YCsTdAALAAEWKFRLd3e3pwobmAV-; fbm_124024574287414=base_domain=.instagram.com; csrftoken=5vKHXNOjOClvCD8bAdfAKy1ZkB2hzNoL; ds_user_id=7173231740; sessionid=7173231740%3AcF4KvHLjTPlXIY%3A1; shbid=19550; shbts=1614680856.184628; rur=PRN; fbsr_124024574287414=pHfxKJw4x2eXfpsI2qD1oQ1DAAvfpYPvZlYK9tpeKZY.eyJ1c2VyX2lkIjoiMTAwMDA1NTA4NDA2NDM2IiwiY29kZSI6IkFRQlRmdUZ4eXJMRGdzME5zVlpqelNHaEwycUIyV3J6eHp1c0c4TEZ1NGtKamR1eGx1N0s4UDlvTWZwSWNhZ2lnUThRMFE1aklwOEFhbTZoTElZQUVzdVZRRDJTNVIzT1RoZmwwMTFwQzdJVWRxYjcxTUYtQWcxZjNwZ1Qwa3J5bjNCOGVhRHFmUTgyTEJvblZlWTd5R2dycG1zTlhjdU96TS1RYnlfRmgtYVRBX1BhZTdxZzkyTXVZOWpvQzMtVUY4U1NpU3hZNTNzWUZIaVBvRDFXUXlzV3JiQTdDVEhtd3lkQV82R3BSVVhzZlI4dGV0cDQ3NGFlbFBkRnFBTF9taFBvRlF1bHlsaUt2a1JJYmprUmd2bm9QWmxJbTgyWHNGSkpjaW5LYVBScm55MmJ0Q3lDN0NhSHBfb29qT2ZoZmlYSFdNMzdhTldoUlhneko4MGxJN0R5SWMtRHFGLTlPRzZQLVpEMXJwRGZPUSIsIm9hdXRoX3Rva2VuIjoiRUFBQnd6TGl4bmpZQkFPMkxwQ2hGcnk5TlpDSEo1dGtBcnQwWkNKSGRnSWg4Qkl6cFpCeHZiRVFPSVpDT0wzb0ZvMlByZmZNYzZ6TmVFUWs5MnM3RTJjUmhCQ3VjT0FLaGFtdFVaQjh2ZjVWUXNQbkJwZ1Z3TDNudzlZajBmVFpDT2VKWkFjZzlva09CcUQ5a3Rxd0plYmlaQzdEYlE1dE9nb2lnSFdQWEJPM1RQVXVlOG9MbTljTWoiLCJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTYxNDY4OTg5N30"; const userID = "6958719470"; let end_cursor = ""; let has_next_page = true; let results = []; while (has_next_page) { let url = 'https://www.instagram.com/graphql/query/?query_hash=003056d32c2554def87228bc3fd9668a&variables={"id":"' + userID + '","first":12,"after":"' + end_cursor + '"}'; const response = await fetch(url, { headers: { cookie: cookie, }, }); const json = await response.json(); has_next_page = json.data.user.edge_owner_to_timeline_media.page_info.has_next_page; end_cursor = json.data.user.edge_owner_to_timeline_media.page_info.end_cursor; let edges = json.data.user.edge_owner_to_timeline_media.edges; edges.map((edge) => { let is_video = edge.node.is_video; let taken_at_timestamp = edge.node.taken_at_timestamp; let edge_media_to_caption = edge.node.edge_media_to_caption.edges[0] ? edge.node.edge_media_to_caption.edges[0].node.text : ""; let edge_media_preview_like = edge.node?.edge_media_preview_like.count; let shortcode = edge.node.shortcode; let display_url = []; if (is_video) { let video_view_count = edge.node?.video_view_count; display_url.push({ is_video, src: edge.node.video_url, video_view_count, }); } else if ( !is_video && edge.node.edge_sidecar_to_children !== undefined ) { let items = edge.node.edge_sidecar_to_children.edges; items.map((item) => { display_url.push({ is_video: item.node.is_video, src: item.node.is_video ? item.node.video_url : item.node.display_url, video_view_count: item.node?.video_view_count, }); }); } else { display_url.push({ is_video, src: edge.node.display_url, }); } results.push({ taken_at_timestamp, edge_media_to_caption, edge_media_preview_like, display_url, shortcode, }); }); } fs.writeFileSync( "./hoang.yennn_.json", JSON.stringify((display_resources = results)) ); })();