<commit_before>var $ = require('jquery');

var getFeed = function(username) {

	var dfd = $.Deferred();

	var requestHTML = $.ajax({
		type: "GET",
		url: 'http://hubski.com/feed?id=' + username,
		datatype: 'html',
		success: function(data) {
			var feedJSON = parseFeedJSON(data);
			dfd.resolve(feedJSON);
		}
	});

	return dfd.promise();
}

exports.getFeed = getFeed;

var parseFeedJSON = function(html) {
	var baseURL = 'http://hubski.com/';
	// Setup our posts array which will contain all of the post objects

	var posts = [];
	$doc = $(html);

	// Get the first node in the grid
	for(var node = $doc.find('#grid > #unit:first'); node.is('div.box'); node = node.next()) {
		// Create an empty post object
		var post = {};

		var title = node.find('.feedtitle > a').html();
		var link = node.find('.feedtitle > a').attr('href');

		/* 
		 * You can check to see if this is a upvote or downvote
		 * by looking for the &dir= property
		 */
		var voteLink = node.find('.plusminus > a').attr('href');
		var topCommentor = node.find('.topcommentor > a').html();
		var topCommentorLink = baseURL + node.find('.topcommentor > a').attr('href');
		var commentsLink = baseURL + node.find('.feedcombub > a').attr('href');	
		

		/* 
		 * The method to get the number of comments is to get the
		 * raw html of the parent <a> and remove the img tag and
		 * any whitespace.
		 */

		var numOfComments = node.find('.feedcombub > a').html();
		var num = removeTagFromString(numOfComments,'img');

		var byName = node.find('.feedsubtitle > a').html();
		var by = removeTagFromString(byName,'font');

		
		var tag = node.find('.feedsubtitle > span > span > a').html();
		
		/*
		for( tag in tagsHTML) {
			console.log(tag);
			console.log(tag.html());
			var tagName = removeTagFromString(tag,'font');
			var tagLink = baseURL + tag.attr('href');

			tags.push({'tagName': tagName,'tagLink':tagLink});
		}
		*/

		post = {'title': title, 'link': link, 'voteLink': voteLink, 'topCommentor': topCommentor, 'topCommentorLink': topCommentorLink, 'commentsLink': commentsLink, 'numOfComments': num,'tags': tag, 'by': by};

		posts.push(post);
	}
	var feed = {"posts": posts};

	return feed;
}

exports.parseFeedJSON = parseFeedJSON;

function removeTagFromString(string, tag) {
	var re = new RegExp('<'+tag+'.*/>','g');
	var returnStr = string;
	returnStr = string.replace(re,'');
	returnStr = returnStr.replace('<'+tag+'/>','');
	return returnStr;
}<commit_msg>Changed json variable naming to match csharp conventions to make it easier to use json.net<commit_after>var $ = require('jquery');

var getFeed = function(username) {

	var dfd = $.Deferred();

	var requestHTML = $.ajax({
		type: "GET",
		url: 'http://hubski.com/feed?id=' + username,
		datatype: 'html',
		success: function(data) {
			var feedJSON = parseFeedJSON(data);
			dfd.resolve(feedJSON);
		}
	});

	return dfd.promise();
}

exports.getFeed = getFeed;

var parseFeedJSON = function(html) {
	var baseURL = 'http://hubski.com/';
	// Setup our posts array which will contain all of the post objects

	var posts = [];
	$doc = $(html);

	// Get the first node in the grid
	for(var node = $doc.find('#grid > #unit:first'); node.is('div.box'); node = node.next()) {
		// Create an empty post object
		var post = {};

		var title = node.find('.feedtitle > a').html();
		var link = node.find('.feedtitle > a').attr('href');

		/* 
		 * You can check to see if this is a upvote or downvote
		 * by looking for the &dir= property
		 */
		var voteLink = node.find('.plusminus > a').attr('href');
		var topCommentor = node.find('.topcommentor > a').html();
		var topCommentorLink = baseURL + node.find('.topcommentor > a').attr('href');
		var commentsLink = baseURL + node.find('.feedcombub > a').attr('href');	
		

		/* 
		 * The method to get the number of comments is to get the
		 * raw html of the parent <a> and remove the img tag and
		 * any whitespace.
		 */

		var numOfComments = node.find('.feedcombub > a').html();
		var num = removeTagFromString(numOfComments,'img');

		var byName = node.find('.feedsubtitle > a').html();
		var by = removeTagFromString(byName,'font');

		
		var tag = node.find('.feedsubtitle > span > span > a').html();
		
		/*
		for( tag in tagsHTML) {
			console.log(tag);
			console.log(tag.html());
			var tagName = removeTagFromString(tag,'font');
			var tagLink = baseURL + tag.attr('href');

			tags.push({'tagName': tagName,'tagLink':tagLink});
		}
		*/

		post = {'Title': title, 'Link': link, 'VoteLink': voteLink, 'TopCommentor': topCommentor, 'TopCommentorLink': topCommentorLink, 'CommentsLink': commentsLink, 'NumberOfComments': num,'Tag': tag, 'Author': by};

		posts.push(post);
	}
	var feed = {"posts": posts};

	return feed;
}

exports.parseFeedJSON = parseFeedJSON;

function removeTagFromString(string, tag) {
	var re = new RegExp('<'+tag+'.*/>','g');
	var returnStr = string;
	returnStr = string.replace(re,'');
	returnStr = returnStr.replace('<'+tag+'/>','');
	return returnStr;
}
{'fraction_non_alphanumeric': 0.17453303876280377, 'fraction_numerical': 0.0, 'mean_word_length': 3.806949806949807, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1906918', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1615, 'n_words': 452}