Skip to content

Instantly share code, notes, and snippets.

@cou929
Created March 31, 2011 05:40
Show Gist options
  • Save cou929/895872 to your computer and use it in GitHub Desktop.
Save cou929/895872 to your computer and use it in GitHub Desktop.
Extract list of community member data from "http://nodeguide.com/community.html" and make hatena notation.
var ul = document.querySelectorAll("ul");
var i;
var out = "";
for (i=2; i<ul.length; i++) {
var li = Array.slice.call(ul[i].querySelectorAll("li"));
li.map(function(x) {
var c = x.childNodes;
if (c.length === 1) {
var del = c[0].nodeValue.indexOf(":");
var head = c[0].nodeValue.substr(0, del-1);
var con = c[0].nodeValue.substr(del+1);
out += "|*" + head + " | " + con + " | <br />";
} else {
var head = c[0].nodeValue.substr(0, c[0].nodeValue.length - 2);
var url = c[1].getAttribute('href');
var con = c[1].childNodes[0].nodeValue;
out += "|*" + head + " | [" + url + ":title=" + con + "] | <br />";
}
});
out += "<br />"
}
var div = document.createElement("div");
div.innerHTML = out;
document.body.appendChild(div);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment