alsotang / node-lessons

:closed_book:《Node.js 包教不包会》 by alsotang
16.54k stars 4.7k forks source link

lesson3 爬优酷的时候出现的问题 #101

Open izayl opened 8 years ago

izayl commented 8 years ago

Error: connect ECONNREFUSED at exports._errnoException (util.js:746:11) at TCPConnectWrap.afterConnect as oncomplete

aimer1124 commented 8 years ago

@izayl 可以啊。

<div class="yk-logo">
                <a href="http://www.youku.com/" title="Youku 优酷" attr="idx0"><img src="http://static.youku.com/youku/dist/img/find/yk-logo-0412.png" width="140" height="50" alt="Youku 优酷" from="index"></a>
            </div>

app.get('/', function (req, res, next) {
    superagent.get('http://www.youku.com/')
        .end(function (err, sres) {
            if (err) {
                return next(err);
            }
            var $ = cheerio.load(sres.text);
            res.send($('.yk-logo').find('a').attr('title'));
        });
});