alsotang / node-lessons

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

lessons 4 #127

Closed eyea closed 7 years ago

eyea commented 7 years ago

在进行到lesson4的时候 获取40个元素
作者的名字和scores 很多都是undefined的情况 是什么原因呢 ?

        ep.after('author_html', authorUrls.length, function(authors){
            authors = authors.map(function(authorPair){
                var authorUrl = authorPair[0],
                    authorHtml= authorPair[1],
                    $         = cheerio.load(authorHtml);
                return ({
                    author_name: $('.userinfo .user_big_avatar .user_avatar').attr('title') ? $('.userinfo .user_big_avatar .user_avatar').attr('title') : 'alsotang',
                    author_scores: $('.user_profile .unstyled .big').eq(0).text().trim() ? $('.user_profile .unstyled .big').eq(0).text().trim() : 666
                })
            });
            console.log(authorUrls.length);
            console.log('final:');
            console.log(authors);
        });
KokoTa commented 7 years ago

lesson4因为方便所以并发了40个请求, 然而网站有并发限制, 导致无法获取全部请求, lesson5会教我们学会限制并发数, 所以这节课只是了解并发的处理, 下节课就是解决并发数了。

eyea commented 7 years ago

OK,谢谢~