Skip to content

Instantly share code, notes, and snippets.

@grahamb
Created January 21, 2010 07:55
Show Gist options
  • Save grahamb/282655 to your computer and use it in GitHub Desktop.
Save grahamb/282655 to your computer and use it in GitHub Desktop.
// YQL SELECT Query:
// SELECT * FROM html WHERE url="http://www.conquercancer.ca/site/TR?px=1817895&fr_id=1331&pg=personal" AND xpath="//p[@class='Smaller']"
var yql = "http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.conquercancer.ca%2Fsite%2FTR%3Fpx%3D1817895%26fr_id%3D1331%26pg%3Dpersonal%22%20AND%20xpath%3D%22%2F%2Fp%5B%40class%3D'Smaller'%5D%22&format=json&diagnostics=false&callback=?";
$.ajax({type:'GET', url: yql, dataType:'jsonp', success: function(data, textStatus) {
var amount = $.trim(data.query.results.p.content).substr(10),
dollarsign = amount.substr(0, 1),
cents = amount.substr((amount.length)-2),
dollars = amount.substr(1, amount.indexOf('.')-1),
html = ['<span class="dollarsign">', dollarsign, '</span>', dollars, '<span class="cents">', cents, '</span>'].join('');
$('#amount_raised').html(html);
}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment