使用Yahoo Pipe Service来聚合你关注的博客

ThoughtWorks好声音 ThoughtWorks好声音是一个聚合网站,内容来自众ThoughtWorker的博客,我们每周会汇聚一次,从众多的博客中挑选出一些P2(软件卓越)相关的主题,然后编为一辑,再分享出去。 但是从近100个博客中找P2相关的内容,这件事本身非常繁琐,如果每周都做这个重复劳动的话,那么软件卓越从何谈起呢?作为以解放人类为己任的程序员,我们绝对不能忍受纯体力的劳动。 获取博客地址列表 之前郑晔做了一个金数据的统计,请各位同事把自己的名字和博客地址登记在一个金数据的表单上: 接下来第一步就是把网页上的所有地址取下来,这一步很容易,从金数据的页面上用jQuery找到表格的第二列,然后将其中的文字取出来: $("table tr td:nth-child(2)").map(function(key, item) { return $(item).text().trim(); }); 写到这里突发奇想,能不能用phantomjs去把这个动作自动化? page.open(url, function (status) { if (status !== 'success') { console.log('Unable to access network'); } else { page.injectJs('jquery.js'); var links = page.evaluate(function() { return $("table tr td:nth-child(2)").map(function(key, value) { return $(value).text().trim(); }); }); var results = underscore(links).filter(function(item) { return item.length > 0; }).map(function(item) { if(!new RegExp('^(https|http)').test(item)) { return "http://" + item; } return item; }); } phantom....

January 1, 2014 1 min