Skip to content

Instantly share code, notes, and snippets.

@chrisle
Last active July 2, 2016 01:57
Show Gist options
  • Select an option

  • Save chrisle/9d944c2da0e3f43940424f2c1f1eef6f to your computer and use it in GitHub Desktop.

Select an option

Save chrisle/9d944c2da0e3f43940424f2c1f1eef6f to your computer and use it in GitHub Desktop.
Scrape Billboard Hot 100 and create an array of objects
/**
* Install x-ray with: 'npm install x-ray'
* (Also see: https://github.com/lapwinglabs/x-ray)
*
* Run with: node scraper.js
*/
var Xray = require('x-ray');
var scraper = Xray({
filters: {
trim: function (value) {
return typeof value === 'string' ? value.replace(/\n/g, '').trim() : value
}
}
});
scraper('http://www.billboard.com/charts/hot-100', '.chart-row__main-display',
[{
rankCurrent: '.chart-row__current-week',
rankLast: '.chart-row__last-week',
title: '.chart-row__song | trim',
artist: '.chart-row__artist | trim'
}]
)(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment