Skip to content

Instantly share code, notes, and snippets.

@yatt
Created March 22, 2012 16:31
Show Gist options
  • Select an option

  • Save yatt/2159392 to your computer and use it in GitHub Desktop.

Select an option

Save yatt/2159392 to your computer and use it in GitHub Desktop.
bashでいかにしておっぱい画像をダウンロードするか〜2012
#! /bin/sh
# サンプル: 5並列でキーワード「XXX」で画像検索、ダウンロード
# $ for n in $(seq 0 50 199); do sh ~/bing.sh XXX $n 50 | xargs -t -P 5 -L 10 wget -q;done
KEY=# assign your application key; bing api requires application key
QUERY=$(python -c "import urllib; print urllib.quote('$1')")
START=0
COUNT=50
if [ $# -gt 1 ];
then
START=$2
fi
if [ $# -gt 2 ];
then
COUNT=$3
fi
URL="http://api.bing.net/json.aspx?AppId=$KEY&Version=2.2&Market=ja-JP&Query=$QUERY&Sources=Image&Image.Count=$COUNT&Image.Offset=$START&Adult=Off"
wget -q -O - $URL \
| sed -e 's/"MediaUrl":/\n/g' -e 's/,"Url"/\n/g'\
| /bin/grep '^"' \
| sed -e 's/"\(.*\)"/\1/g' -e 's/\\//g' \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment