Skip to content

Instantly share code, notes, and snippets.

@rebornix
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebornix/3d5d6503535196b6cd67 to your computer and use it in GitHub Desktop.
Save rebornix/3d5d6503535196b6cd67 to your computer and use it in GitHub Desktop.
Extract information from Stack Overflow question with Noodlejs
var query = {
url: 'http://stackoverflow.com/questions/31095166/angular-mocha-tests-fail-when-i-add-multiple-controllers-to-the-same-module',
type: 'html',
map: {
title: {
selector: "#question-header h1 a",
extract: "text"
},
description: {
selector: ".question .postcell .post-text",
extract: "text"
},
questionupvote: {
selector: ".question .votecell .vote-count-post",
extract: "text"
},
tags: {
selector: ".question .postcell .post-taglist a",
extract: "text"
},
answer: {
selector: ".accepted-answer .post-text",
extract: "text"
},
anwserupvote: {
selector: ".accepted-answer .votecell .vote-count-post",
extract: "text"
},
}
},
uriQuery = encodeURIComponent(JSON.stringify(query)),
request = 'http://example.noodlejs.com/?q=' +
uriQuery + '&callback=?';
// Make Ajax request to Noodle server
jQuery.getJSON(request, function (data) {
alert(data[0].results);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment