Skip to content

Instantly share code, notes, and snippets.

@sayanee
Created May 2, 2019 14:53
Show Gist options
  • Save sayanee/7d8eb304f133ea3c5a3007e830e09209 to your computer and use it in GitHub Desktop.
Save sayanee/7d8eb304f133ea3c5a3007e830e09209 to your computer and use it in GitHub Desktop.
var osmosis = require('osmosis')
var ingredient = 'Sodium Benzoate'
osmosis
.get('https://www.ewg.org/skindeep/search.php?query=' + ingredient + '&h=Search')
.find('#table-browse > tr[2]')
.set({
'ingredient': 'td[2]',
'score': 'td[3] > div > div > a > img@src'
})
.data(function(listing) {
console.log(listing.ingredient)
var paragraph = listing.score
var regex = /image\d/g
var found = paragraph.match(regex)
console.log('SCORE: ' + found[0].replace(/image/g,''))
})
// .log(console.log)
// .error(console.log)
// .debug(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment