Skip to content

Instantly share code, notes, and snippets.

@geopelia
Created August 5, 2014 18:40
Show Gist options
  • Save geopelia/b2391af99f1d189498fa to your computer and use it in GitHub Desktop.
Save geopelia/b2391af99f1d189498fa to your computer and use it in GitHub Desktop.
Script para bajar imagenes al azar desde www.imagenesbing.com
#!/bin/bash
host="http://www.imagenesbing.com/"
file="$HOME/temp1.html"
imgfolder="$winhome/Pictures/walls"
curl --silent $host -o $file
max_value=`grep -E -o '/i/[0-9]+' $file | grep -E -o '[0-9]+' | awk '$0>x{x=$0};END{print x}' `
# Generate multiple values
#for i in {1..5}; do echo $((RANDOM %= $max)); done
imageid=$((RANDOM %= $max_value))
imageurl="i/$imageid"
imagepath=`curl --silent "$host$imageurl" | grep -o 'bingimages/[^"]*' | head -n 1`
cd "$imgfolder" && { curl --silent -O "$host$imagepath" ; cd -; }
rm $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment