mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2024-12-29 16:10:12 +08:00
Adding .getAllComments()
This commit is contained in:
parent
b9ec1ccfb5
commit
444649ee8c
@ -113,3 +113,7 @@ CSteamGroup.prototype.kick = function(steamID, callback) {
|
||||
CSteamGroup.prototype.getHistory = function(page, callback) {
|
||||
this._community.getGroupHistory(this.steamID, page, callback);
|
||||
};
|
||||
|
||||
CSteamGroup.prototype.getAllComments = function(from, count, callback) {
|
||||
this._community.getAllGroupComments(this.steamID, from, count, callback);
|
||||
};
|
||||
|
@ -517,3 +517,44 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
||||
callback(null, output);
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callback) {
|
||||
var options = {};
|
||||
options.uri = "http://steamcommunity.com/comment/Clan/render/" + gid.getSteamID64() + "/-1/";
|
||||
options.method = "POST";
|
||||
options.body = "start=" + from + "&count=" + count;
|
||||
|
||||
var self = this;
|
||||
this.httpRequest(options, function(err, response, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var comments = [];
|
||||
|
||||
body = JSON.parse(body);
|
||||
body = body.comments_html;
|
||||
|
||||
$ = Cheerio.load(body);
|
||||
|
||||
$(".commentthread_comment_content").each(function () {
|
||||
var comment = {};
|
||||
var cachedSelector;
|
||||
|
||||
cachedSelector = $(this).find(".commentthread_author_link");
|
||||
comment.authorName = $(cachedSelector).find("bdi").text();
|
||||
comment.authorId = $(cachedSelector).attr('href').replace("http://steamcommunity.com/id/", "");
|
||||
comment.date = $(this).find(".commentthread_comment_timestamp").text().trim();
|
||||
|
||||
cachedSelector = $(this).find(".commentthread_comment_text");
|
||||
|
||||
comment.commentId = $(cachedSelector).attr('id').replace("comment_content_", "");
|
||||
comment.text = $(cachedSelector).text().trim();
|
||||
|
||||
comments.push(comment);
|
||||
});
|
||||
|
||||
callback(null, comments);
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user