2011-05-10

nodejs 大呼过瘾!!

javascript 真的要火!


这个网页爬虫类库集成多个优秀的类库 可见一斑
http://www.slideshare.net/sylvinus/web-crawling-with-nodejs


目前的类库


比python的命令行还好用
支持高亮 和tab成员枚举 爽呆了

通过ubuntu的ppa安装最新版


安装npm费了点事 需要一点准备工作
主要是npm需要系统用node来执行nodejs 而上面的ppa只建立了nodejs 命令

我现在还搞不清楚 linux的好几种link方式
用了硬link 可能不是最好的方案
link nodejs node

然后执行 curl http://npmjs.org/install.sh | sh  需要切换到root

sudo su

-------------------------------------------------------------------------


下午写了一个豆腐块 呵呵 

var url=require('url');
var get = require('get');
var htmlparser = require("htmlparser");
var select = require('soupselect').select;


download.proxy=url.parse(process.ENV.http_proxy);

download.asString(function(err, wp) {
    var handler = new htmlparser.DefaultHandler(function (error, dom) {
select(dom, "area").forEach(function(element) {console.log(element);});
    });
    var parser = new htmlparser.Parser(handler);
    parser.parseComplete(wp);
});

how to get a element's eventlistener


发展真快啊 几个月前找这个问题还没有答案 现在chrome和firebug都给了答案

http://stackoverflow.com/questions/4672301/getting-an-elements-eventlisteners
In safari's (and chrome's) element inspector there's an "Event Listeners" section (in the right frame of the elements tab) that show's the Event Listeners in the document. Is there anything similar in firebug? Also, is it possible to get an element's event listeners using javascript (like elmnt.onclick, but should work for events added with addEventListener() as well)?    

This is available for firebug:

http://getfirebug.com/wiki/index.php/Firebug_Extensions#Eventbug

For your second question, is it possible to get the events added via addEventListener in javascript? Generally it is not. That add-on uses eventlistenerservice you would need elevated privileges, a signed script and it would still only work in Firefox.

Eventbug

Eventbug

Eventbug is a Firebug extension that lists all of the event handlers on the page grouped by event type...

所见所闻所思