Skip to content

Instantly share code, notes, and snippets.

@codeasashu
Created June 2, 2016 20:56
Show Gist options
  • Select an option

  • Save codeasashu/b769dfde47293d20084ee843076b054c to your computer and use it in GitHub Desktop.

Select an option

Save codeasashu/b769dfde47293d20084ee843076b054c to your computer and use it in GitHub Desktop.
NodeJS program to fetch top image text
var cheerio = require('cheerio');
var request = require('request');
var b;
request
({
method: 'GET',
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11'
},
url: 'https://www.google.com/searchbyimage?&image_url=http://www.pentel.com/store/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/N/X/NXS15-C.png'
}, function(err, response, body) {
if (err) return console.error(err);
$ = cheerio.load(body);
$('div#topstuff').find('div.card-section > div._hUb > a').each(function (index, element, body) {
var b = $(this).text();
console.log(b);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment