Created
August 5, 2014 18:40
-
-
Save geopelia/b2391af99f1d189498fa to your computer and use it in GitHub Desktop.
Script para bajar imagenes al azar desde www.imagenesbing.com
This file contains hidden or 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
#!/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