Created
January 25, 2015 00:07
-
-
Save davidkryzaniak/9e2a78265f69ef6fe150 to your computer and use it in GitHub Desktop.
MakeRequest.js
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
var page = require('webpage').create(); | |
var agents = Array( | |
'Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19', | |
'Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3', | |
'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3', | |
'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0', | |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0', | |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36', | |
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36', | |
'Mozilla/5.0 (compatible; WOW64; MSIE 10.0; Windows NT 6.2)', | |
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)', | |
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)', | |
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27' | |
); | |
//Pick a random user agent | |
page.settings.userAgent = agents[Math.floor(Math.random() * agents.length)]; | |
//Open the connection | |
page.open('http://example.com/', function(status) { | |
if (status !== 'success') {console.log('Unable to access network');} | |
//Gotta go! | |
phantom.exit() | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment