Created
January 29, 2014 22:30
-
-
Save robertbrook/8698553 to your computer and use it in GitHub Desktop.
This file contains 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 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