From: Mischa POSLAWSKY Date: Sat, 23 May 2020 03:06:00 +0000 (+0200) Subject: word: mkimg-google tool to download images X-Git-Tag: v1.13~268 X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/16d65f639cb7e2c16257036c6a4efa2d15019857 word: mkimg-google tool to download images Automatic population with top results searching each term: perl -E 'sub flat {map { ref ? flat(@$_) : $_ } @_} say for flat do "./wordlist.inc.pl"' Good for testing; definitely requires further moderation to release: avoiding false friends (e.g. mug commonly isn't a midge), finding better representations, and at least nicely cropping to aspect ratio. --- diff --git a/tools/mkimg-google b/tools/mkimg-google new file mode 100755 index 0000000..1e1f7a8 --- /dev/null +++ b/tools/mkimg-google @@ -0,0 +1,13 @@ +#!/bin/sh +CURL='curl -sSf' +QUERYURL="https://www.google.com/search?tbm=isch&pws=0&hl=nl&num=1&q=" +ARGMATCH=']+src="(http[^"]+)"' + +for q in "$@" +do + [ -e "$q.jpg" ] && continue + echo "$q" + QUERYARG="%22$q%22" + QUERYRES=$($CURL "$QUERYURL$QUERYARG" | perl -nE "say for /$ARGMATCH/" | head -1) + $CURL "$QUERYRES" -o "$q.jpg" || continue +done