node js解析程序发送重复文本

时间:2018-05-18 12:06:51

标签: node.js request cheerio

var request = require('request'),

cheerio = require('cheerio');

var i = 1

function parsing(){
    var address='http://gallog.dcinside.com/inc/_mylog.php? 
    gid=chermy018&oneview=Y&cid=59&page=';
    var address1='http://gallog.dcinside.com/inc/_mylog.php? 
    gid=chermy018&oneview=Y&cid=59&page=';

    var k = address+'i';
    var k1 = address1+'i';

    var options = {
        url:k,
        method:'POST',
        headers: {
            'Host': 'gallog.dcinside.com',
            'Connection': 'keep-alive',
            'Upgrade-Insecure-Requests': 1,
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
            'Accept': ,
            'Referer': k1,
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
            'Cookie': ,
         }
    };

    request(options, function (err, response, body) {
        var $ = cheerio.load(body);
        var text1=$('#memo_content').text();
        console.log(text1);
    });

    i++;

    var time=setTimeout(parsing, 1000);

    if(i==4){
        clearTimeout(time);
    }

}

parsing();

我修改了代码。第一个'为'我做的语法似乎可能太快服务器惹恼了刮板。第二我使用了复发功能。它解决了问题结果奇怪的符号。但它从服务器发送undefined。最后我使用了cheerio语法,所以我发现undefined没有发生,它发送我的文本。但它重复了第一页的文字。

0 个答案:

没有答案