NOTE: This documentation/tool is for personal backup use ONLY. This is intentionally NOT built to be a "once and done" script to prevent abuse of the Instagram terms.
- Go to an Instagram user's page and grab all URLs using the Javascript console. Try the following command:
Array.prototype.slice.call(document.getElementsByTagName("img")).map(e => e.getAttribute("src")).join("\n")
- Copy and paste all the URLs you want to backup into a text file, such as
files.txt
. Make sure all URLs begin with the right base (in this case,instagram.com
).
https://instagram.fphl2-4.fna.fbcdn.net/v/t51.2885-19/s320x320/89473677_2499649937031716_2450743282951520256_n.jpg?_nc_ht=instagram.fphl2-4.fna.fbcdn.net&_nc_ohc=Od441iwkPQoAX-hruDl&oh=261ba8060830f7c127644d234aa97c20&oe=5EE97402
https://instagram.fphl2-3.fna.fbcdn.net/v/t51.2885-15/sh0.08/e35/c0.180.1440.1440a/s640x640/96860792_523158148562685_7608590519194590096_n.jpg?_nc_ht=instagram.fphl2-3.fna.fbcdn.net&_nc_cat=109&_nc_ohc=hLMeMxJDnf8AX8bzBJa&oh=68b0cd7418d27eba9813928c5502fc7e&oe=5EE96C09
...
- Run the following batch
curl
command from the location where you savedfile.txt
using Terminal/iTerm:
xargs -n 1 curl -O < files.txt
- You may notice that the downloaded files do not have a valid file extension due to the long URL queries at the end. You can use the homebrew tool rename (install with
brew install rename
) to fix this pretty easily:
rename --append .jpg *
- ๐ Done! Enjoy your folder of photos. To ensure as many high quality photos are saved as possible, browse the user's page for a while before running the command.
Use the following script that tries to pull the image from an open dialog using a silly little padding-bottom check. It should open the image in a new window:
for (const i of Array.prototype.slice.call(document.getElementsByTagName("img")).filter(e => e.parentNode.style.paddingBottom === "125%").map(e => e.getAttribute("src"))) {
const f = document.createElement('a');
f.href = i;
f.download = i;
document.body.appendChild(f);
f.click();
document.body.removeChild(f);
}
As a bookmarklet:
javascript:(function(){for(const e of Array.prototype.slice.call(document.getElementsByTagName("img")).filter(e=>e.parentNode.style.paddingBottom).map(e=>e.getAttribute("src"))){const t=document.createElement("a");t.href=e,t.download=e,document.body.appendChild(t),t.click(),document.body.removeChild(t)}})();```