Last active
August 28, 2017 10:39
-
-
Save eikw/3c9f50441179b0078d41d8ba0ef2c4b6 to your computer and use it in GitHub Desktop.
Initial Test
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 http = require('http'); | |
var url = require('url'); | |
var cheerio = require('cheerio'); | |
var result = []; | |
var myURL = url.parse(process.argv[2]); | |
var options = { | |
host: myURL.host, | |
path: myURL.pathname | |
} | |
var request = http.request(options, function (res) { | |
var data = ''; | |
res.on('data', function (chunk) { | |
data += chunk; | |
}); | |
res.on('end', function () { | |
$ = cheerio.load(data); | |
conferences = $(".listing"); | |
for(var i=0; i < conferences.length; i++){ | |
x = cheerio.load(conferences[i]); | |
header = x(".conferenceHead a"); | |
venue = x(".venue_info a"); | |
date = x(".conferenceDate .begin_txt a"); | |
var events = { | |
title: header[0].children[0].data, | |
venue: venue[0].children[0].data, | |
begins: date[0].children[0].data | |
}; | |
result.push(events); | |
} | |
console.log(result); | |
}); | |
}); | |
request.on('error', function (e) { | |
console.log(e.message); | |
}); | |
request.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment