Comparing versions 1 and 2.
UpcoingOrgInfotron
This blueprint is supposed to be connected upstreams to an ajaxwrapper which feed data from the Upcoming.org events site API, so it is kind of specialized. However it is a good template for when you need to do some similar scraping.
BLUEPRINT(
"~01E0DFBB311ED2450cA5AF88A762A653BA",
[
["xml_json_in", "onJsonXml", 10]
],
[
"collection_out"
],
function (Class)
{
Class.prototype.onJsonXml = function(msg)
{
var coll = [];
var n, event, events;
try {
events = msg.children;
n = events.length;
} catch (ex) {
this.error(ex, "malformed JSON RSS output");
return;
/*****************************************************************/
/*****************************************************************/
}
for (i = 0; i < n; i++) {
event = events[i];
if (event.attributes) {
coll.push({name:event.attributes["name"],
text_content:event.attributes["description"],
lat:parseFloat(event.attributes["latitude"]),
lon:parseFloat(event.attributes["longitude"]),
date:[new Date(event.attributes["start_date"].replace(/-/g, "/") + " " + event.attributes["start_time"]),
new Date(event.attributes["end_date"].replace(/-/g, "/") + " " + event.attributes["end_time"])]});
}
}
}
this.postMessage("collection_out", coll);
};
}, "Upcoming.org XML JSON to Collection");