Skip to content

Instantly share code, notes, and snippets.

@pettazz
Created September 15, 2016 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pettazz/5975b296fe3bbe187e856f73d7eeda67 to your computer and use it in GitHub Desktop.
Save pettazz/5975b296fe3bbe187e856f73d7eeda67 to your computer and use it in GitHub Desktop.
get all the urls from a wedding photo website because im lazy and i wanted to download them all
var urls = [];
var thumbs = $('.tab-frame-content .pg img.pv-img');
var doit = function(idx){
if(idx < thumbs.length){
var el = $(thumbs[idx]);
var link = el.parent('a');
link.trigger('mousedown');
var timeoutID = window.setTimeout(function(){
$('.pf-plane > .pv-ready .pv-inner > img.pv-img').each(function(){
var style = $(this).attr('style');
if(style){
urls.push(style.match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, ""));
}
});
doit(idx + 1)
}, 2000);
}else{
if($("a#_aab-n").css("visibility") !== "hidden"){
$("a#_aab-n").trigger('mousedown');
var timeoutID = window.setTimeout(function(){
thumbs = $('.tab-frame-content .pg img.pv-img');
doit(0);
}, 4000);
}else{
console.log(urls);
}
}
};
doit(0);
@pettazz
Copy link
Author

pettazz commented Sep 19, 2016

  • do that ^ in console
  • prepend the url base and copy the array to clipboard:
copy(JSON.stringify(urls.map(function(url){ return "http://www.hahaha-ohwow-photos-website.com/" + url; });));
  • paste in a file and save as something like pics.json
  • download them all with reasonable filenames in bash:
arr=( $(cat pics.json | jq -r '.[]'))
mkdir pics
cd pics
for i in "${arr[@]}"; do echo $i; curl -O -s -S $i; done
for f in *.jpg*; do mv "$f" "${f/.jpg*/.jpg}"; done

There's probably a more clever way to rename with curl but did I mention I am laaaaaaaaaazy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment