Last active
August 29, 2015 14:08
-
-
Save duyet/027368e0fff8cd295d26 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
lib = | |
fs : require('fs') | |
u : require('underscore') | |
https : require('https') | |
url : require('url') | |
appendToFile = (data) -> | |
lib.fs.open 'fbdata', 'a', (e, fd) -> | |
lib.fs.write fd, data, null, 'utf8', -> | |
lib.fs.close fd, -> | |
facebookCrawl(JSON.parse(data).paging.next) | |
facebookCrawl = (link) -> | |
url = lib.url.parse(link) | |
lib.https.get {host:url.host, path:url.path}, (res) -> | |
res.setEncoding('utf8') | |
body = "" | |
res.on('data', (d) -> body += d) | |
res.on('end', -> appendToFile(body)) | |
res.on('error', (e) -> console.log("https error: #{e}")) | |
# Start crawler | |
accessToken = "" | |
facebookCrawl("https://graph.facebook.com/me/feed?access_token=#{accessToken}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment