Created
November 16, 2014 15:45
-
-
Save ToastHelmi/40fed1dc0c01b92d6dc3 to your computer and use it in GitHub Desktop.
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
var Crawler = require("simplecrawler"); | |
var querystring = require('querystring'); | |
var myCrawler = new Crawler("www.geocaching.com", "/login/"); | |
myCrawler.initialProtocol = "https"; | |
myCrawler.acceptCookies = true; | |
myCrawler.on("addcookie", function (cookie) { | |
console.log("Cookie"); | |
}); | |
myCrawler.on("crawlstart", function () { | |
console.log("Crawler start") | |
}); | |
myCrawler.on("fetchstart", function (queueItem, requestOptions) { | |
if (requestOptions.host + requestOptions.path == "www.geocaching.com/login/"){ | |
requestOptions.method = 'POST'; | |
requestOptions.headers['User-Agent'] = "Mozilla/5.0 (Windows NT 6.a; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"; | |
requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded'; | |
var form = { | |
"_EVENTTARGET": "", | |
"_EVENTARGUMENT": "", | |
"_VIEWSTATE": "", | |
"ctl00$ContentBody$tbUsername": "user", | |
"ctl00$ContentBody$tbPassword":"pass", | |
"ctl00$ContentBody$btnSignIn": "Sign+In" | |
}; | |
var formData = querystring.stringify(form); | |
var contentLength = formData.length; | |
requestOptions.headers['Content-Lenght'] = contentLength; | |
requestOptions.body = formData; | |
//console.log(requestOptions); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment