Created
January 30, 2017 12:41
-
-
Save khushalbokadey/b4319c522d59584bd39eaf1103f9e024 to your computer and use it in GitHub Desktop.
Get all answers of a user from Quora
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 fs = require('fs'); | |
var quora = require('quora-api'); | |
var _ = require('lodash'); | |
var json2csv = require('json2csv'); | |
var questions = ['How-can-I-make-my-room-look-nicer-on-a-budget']; | |
module.exports = { | |
execute: function(callback) { | |
async.eachSeries(questions, function(question, cb) { | |
quora.answer.user(question + '/answer/Shriram-Kumar-14') | |
.then(answer => { | |
var csv = json2csv({ | |
data: { | |
question: question, | |
answer: answer.answer | |
}, | |
fields: ['question', 'answer'] | |
}); | |
console.log(question); | |
setTimeout(function() { | |
console.log("Waiting!!!"); | |
}, 2000); | |
fs.appendFile('/home/khushal/Desktop/quora-1.csv', csv, function(err) { | |
if (err) { | |
return cb(err); | |
} | |
sails.log.verbose('file saved'); | |
return cb(null); | |
}); | |
}); | |
}, callback) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment