Skip to content

Instantly share code, notes, and snippets.

@amoscardino
Last active March 31, 2017 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amoscardino/a16274b7c7c41ef8eb65f5699f97f4fa to your computer and use it in GitHub Desktop.
Save amoscardino/a16274b7c7c41ef8eb65f5699f97f4fa to your computer and use it in GitHub Desktop.
ISPs can now sell your internet history. Make that data less useful.
// You will need some npm packages:
// >npm install an-array-of-english-words node-horseman phantomjs-prebuilt --save
// Run like this:
// >node noisy.js
var delay = 10000; // 10 sec;
// These make the pages load quicker and use fewer resources
var horsemanOptions = {
loadImages: false,
injectJquery: false
};
var words = require('an-array-of-english-words');
var Horseman = require('node-horseman');
var getWord = () => words[Math.floor(Math.random() * words.length)];
var loadPage = () => {
var word = getWord();
console.log(word);
new Horseman(horsemanOptions)
.userAgent('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36')
.open('http://www.google.com')
.type('input[name="q"]', word) // Enter our word into the search box
.click('[name="btnI"]') // Click the "I'm Feeling Lucky" button
.waitForNextPage()
.url()
.then(url => console.log(` -> ${url}`))
.catch(err => console.log(` -> Error.`)) // This is almost always triggered by a timemout.
.finally(() => setTimeout(loadPage, delay))
.close();
};
// Let's go!
loadPage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment