Last active
July 23, 2020 23:15
-
-
Save ZenulAbidin/103291a9d5714e4643bfd0f978092f00 to your computer and use it in GitHub Desktop.
Scrape links of full-resolution images and videos from Instagram stories. Paste in DevTools console to run.
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
l = [] | |
intvl = setInterval(() => { | |
// The first image doesn't have a back button so it's children[0] not children[1] | |
try { | |
a = document.getElementsByClassName('_3MEiY')[0].children[0].children[0].children[2].children[1].children[0].children[0]; | |
} catch (e) { | |
a = document.getElementsByClassName('_3MEiY')[0].children[0].children[0].children[2].children[0].children[0].children[0]; | |
} | |
// If there is a video save its link as well | |
try { | |
p2 = a.getElementsByTagName("VIDEO")[0]; | |
d2 = p2.children[0].src | |
l.push(d2) | |
} catch (e) {} | |
p = a.getElementsByTagName("IMG")[0]; | |
d = p.getAttribute('src') | |
l.push(d) | |
uniq = [...new Set(l)] | |
// I chose 1500 milliseconds to give you time to paste the script in the console | |
// and have it run before you miss the first story. | |
}, 1500) | |
getLinks = () => { | |
clearInterval(intvl) | |
e = document.createElement("div") | |
e.style.display = "none" | |
e.id = "fumblingFoo9123" | |
for (var u of uniq) { | |
e.appendChild(document.createTextNode(u+'\n')) | |
} | |
document.body.appendChild(e) | |
} | |
//Run this, click through all the posts, wait at least 1.5 seconds | |
//(or adjust the interval) and then run getLinks() to get the links in a hidden DIV. | |
//then go to DevTools console and copy the HTML. You may need to manually replace all "&" with "&". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment