Last active
September 19, 2016 11:22
-
-
Save oodavid/5eb9755461079eee5fe0c054b08fd999 to your computer and use it in GitHub Desktop.
Scraper Example
This file contains 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": "scraper", | |
"version": "1.0.0", | |
"description": "Scraper", | |
"main": "scraper.js", | |
"dependencies": { | |
"node-horseman": "^3.1.1", | |
"random-useragent": "^0.3.0" | |
} | |
} |
This file contains 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
'use strict'; | |
var Horseman = require('node-horseman'); | |
var random_useragent = require('random-useragent'); | |
var horseman = new Horseman({ | |
injectJquery: true, | |
timeout: 10000, | |
loadImages: false, | |
// proxy: '36.250.186.100:8888' | |
// proxyType: ... | |
// proxyAuth: ... | |
}); | |
var url = 'http://oodavid.com/'; | |
horseman | |
.userAgent(random_useragent.getRandom()) | |
.open(url) | |
.html() | |
.then(function(body) { | |
console.log(body); | |
return horseman.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
npm install
then
node scraper.js