Skip to content

Instantly share code, notes, and snippets.

@robertbrook
Created January 29, 2014 22:30
Show Gist options
  • Save robertbrook/8698553 to your computer and use it in GitHub Desktop.
Save robertbrook/8698553 to your computer and use it in GitHub Desktop.
var request = require('request');
var cheerio = require("cheerio");
// http://matthewmueller.github.io/cheerio/
request('http://data.parliament.uk/writtenevidence/WrittenEvidence.svc/EvidenceHtml/5533', function (error, response, body) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(body);
var myString = "";
var myState = "default";
$("p span").each(function(index, element) {
if (~(element.attribs['style']).indexOf("bold")) {
myString += element.children[0].data;
myState = "[bold]";
} else {
myState = "[normal]";
myString += element.children[0].data;
myString += "\n";
}
myString += myState;
});
console.log(myString);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment