Created
June 27, 2014 22:12
-
-
Save ngryman/1f814e01bfaf66245f11 to your computer and use it in GitHub Desktop.
Scrapper for Jerem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "grabber", | |
| "version": "0.0.0", | |
| "description": "Jeremy se lance dans le bis", | |
| "main": "grabber.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "", | |
| "license": "ISC", | |
| "dependencies": { | |
| "async": "^0.9.0", | |
| "jsdom": "^0.11.0" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Dependencies. | |
| */ | |
| var jsdom = require('jsdom'); | |
| var async = require('async'); | |
| /** | |
| * Selectors. | |
| */ | |
| const JOB_LINK = '.job-item .job-title .job-link'; | |
| /** | |
| * Entry point. | |
| */ | |
| goTo('https://remixjobs.com', function(err, window) { | |
| var $ = window.jQuery; | |
| var jobReqs = []; | |
| $(JOB_LINK).each(function() { | |
| jobReqs.push( | |
| goTo.bind(this, this.href) | |
| ); | |
| }); | |
| async.parallel(jobReqs, function(err, results) { | |
| var window = results[0]; | |
| var tags = {}; | |
| for (var result in results) { | |
| var window = results[result]; | |
| var $ = window.jQuery; | |
| $('.tags-occupation .tag').each(function() { | |
| tags[this.textContent] = tags[this.textContent] || 0; | |
| tags[this.textContent]++; | |
| }); | |
| } | |
| for (var tag in tags) | |
| console.log($.trim(tag), tags[tag]); | |
| }) | |
| }); | |
| /** | |
| * Misc. | |
| */ | |
| function goTo(url, done) { | |
| jsdom.env({ | |
| url: url, | |
| scripts: ['http://code.jquery.com/jquery.js'], | |
| done: done | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment