Wednesday, 20 May 2020

How can I download google image search results using simple nodejs script?

I am an amateur programmer with limited ability. Thank you for taking the time to read this.I have a simple nodejs post-recording script for my DVR software EPGStation that moves recorded shows and makes .nfo metadata files for kodi. I want to search google images and download the first 3 search results. (I am not in America, so there is no tvdb data I can scrape for the shows).From npm I found a couple packages that seemed to do what I want, and decided to try using image-google-search: https://www.npmjs.com/package/image-search-google. Search results seem to come back in pages/sets of 10.I have set up a google custom search engine, and have the api key. I am able to get results with this:const API_KEY = 'XXXXXXXXXXXX' const CSE_ID = 'YYYYYYYYYY' var searchString = 'ZZZZZZZZ' const imageSearch = require('image-search-google'); var fs = require('fs'); const client = new imageSearch(CSE_ID, API_KEY); const options = {page:1}; client.search(searchString, options).then(images => { return images.map(url => { var dUrl = (url.url); console.log(dUrl); }) }) dUrl returns a list of 10 urls. Each url on a new line. I would like to download the first 3 results to the folder with the video file.As you can probably tell, I have no idea what I am doing. I hope someone can point me in the right direction.

Submitted May 21, 2020 at 04:13AM by WhyIsThisThingOn

No comments:

Post a Comment