retrieve image from google image search

This flow preforms a Google image search with the injected string, extracts the image URL from the returned JSON, makes another request for the image itself, and saves it locally.

[{"id":"f294910.f0d6b7","type":"http request","name":"","method":"GET","ret":"obj","url":"https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q={{payload}}&start=1&userip=MyIP","x":183,"y":173,"z":"81ae8e74.7e517","wires":[["e4eb0650.1b14f8"]]},{"id":"f3c9477d.0c36b8","type":"inject","name":"get image","topic":"","payload":"critter","payloadType":"string","repeat":"","crontab":"","once":false,"x":99,"y":84,"z":"81ae8e74.7e517","wires":[["f294910.f0d6b7"]]},{"id":"ba89cb7c.457638","type":"debug","name":"","active":true,"console":"false","complete":"payload","x":593,"y":393,"z":"81ae8e74.7e517","wires":[]},{"id":"e4eb0650.1b14f8","type":"function","name":"","func":"msg.url = msg.payload.responseData.results[0].url;\n\nreturn msg;","outputs":1,"valid":true,"x":280,"y":253,"z":"81ae8e74.7e517","wires":[["e2bd1b10.1d42e8"]]},{"id":"e2bd1b10.1d42e8","type":"http request","name":"","method":"GET","ret":"bin","url":"","x":399,"y":339,"z":"81ae8e74.7e517","wires":[["ba89cb7c.457638","5a301d20.a5cfe4"]]},{"id":"5a301d20.a5cfe4","type":"file","name":"save image","filename":"image","appendNewline":false,"overwriteFile":"true","x":593,"y":301,"z":"81ae8e74.7e517","wires":[]}]
critterandguitari

Flow Info

created 2 years, 9 months ago

Node Types

Core
  • debug (x1)
  • file (x1)
  • function (x1)
  • http request (x2)
  • inject (x1)

Tags

  • google
  • image
  • search
  • file
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option