[
  {
    "path": ".gitignore",
    "content": "lib-cov\n*.seed\n*.log\n*.csv\n*.dat\n*.out\n*.pid\n*.gz\n\npids\nlogs\nresults\n\nnpm-debug.log\nnode_modules\n"
  },
  {
    "path": "README.md",
    "content": "node-web-scraper\n================\n\nSimple web scraper to get a movie name, release year and community rating from IMDB.\nTo run this example use the following commands:\n\n``` shell\n$ npm install\n$ node server.js\n```\n\n Then it will start up our node server, navigate to http://localhost:8081/scrape and see what happens.\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\"         : \"node-web-scrape\",\n  \"version\"      : \"0.0.1\",\n  \"description\"  : \"Scrape le web.\",\n  \"main\"         : \"server.js\",\n  \"author\"       : \"Scotch\",\n  \"repository\"   : {\n    \"type\" : \"git\",\n    \"url\"  : \"https://github.com/scotch-io/node-web-scraper\"\n  },\n  \"dependencies\" : {\n    \"express\"    : \"latest\",\n    \"request\"    : \"latest\",\n    \"cheerio\"    : \"latest\"\n  }\n}\n"
  },
  {
    "path": "server.js",
    "content": "var express = require('express');\nvar fs      = require('fs');\nvar request = require('request');\nvar cheerio = require('cheerio');\nvar app     = express();\n\napp.get('/scrape', function(req, res){\n  // Let's scrape Anchorman 2\n  url = 'http://www.imdb.com/title/tt1229340/';\n\n  request(url, function(error, response, html){\n    if(!error){\n      var $ = cheerio.load(html);\n\n      var title, release, rating;\n      var json = { title : \"\", release : \"\", rating : \"\"};\n\n      $('.title_wrapper').filter(function(){\n        var data = $(this);\n        title = data.children().first().text().trim();\n        release = data.children().last().children().last().text().trim();\n\n        json.title = title;\n        json.release = release;\n      })\n\n      $('.ratingValue').filter(function(){\n        var data = $(this);\n        rating = data.text().trim();\n\n        json.rating = rating;\n      })\n    }\n\n    fs.writeFile('output.json', JSON.stringify(json, null, 4), function(err){\n      console.log('File successfully written! - Check your project directory for the output.json file');\n    })\n\n    res.send('Check your console!')\n  })\n})\n\napp.listen('8081')\nconsole.log('Magic happens on port 8081');\nexports = module.exports = app;\n"
  }
]