P2PU Course Scrape via YQL
This fiddle scrapes the first 25 people off of the Course Design Orientation page and display their nick and icon
by dandiebolt
HTML
<script src="https://github.com/jquery/jquery-tmpl/raw/master/jquery.tmpl.min.js"></script>
<script id="template" type="text/x-jquery-tmpl">
<ul>
<li><img src="${div["0"].div.div.a.img.src}"><br/>${(div["0"].div.div.a.href).split("/")[2]}</li>
</ul>
<hr/>
</script>
<h2> Roster of Course Design Orientation</h2>
<hr/>
<div id="info"></div>
JavaScript
//%3Fpage%3Dn inserted
var url="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fp2pu.org%2Fgeneral%2Fcourse-design-orientation%3Fpage%3Dn%22%20and%0A%20%20%20%20%20%20xpath%3D%22%2F%2Ftr%5Bstarts-with(%40class%2C'row-')%5D%2Ftd%5Bstarts-with(%40class%2C'col-')%5D%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?";
$.ajaxSetup({async: false});
for (var i=0; i<4; i++) {
//console.log("working on page " + i);
var url1=url.replace("%3Fpage%3Dn","%3Fpage%3D" + i);
$.ajax({
url: url1,
dataType: 'json',
success: function(data) {
//console.log(data.query.results.td);
$("#template").tmpl(data.query.results.td).appendTo("#info");
}
});
}
/*
SELECT *
FROM html
WHERE url="http://p2pu.org/general/course-design-orientation" AND
xpath="//tr[starts-with(@class,'row-')]/td[starts-with(@class,'col-')]"
*/