Created
March 22, 2012 16:31
-
-
Save yatt/2159392 to your computer and use it in GitHub Desktop.
bashでいかにしておっぱい画像をダウンロードするか〜2012
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/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