-6

我会尽量保持简短;我正试图从这个网站上抓取信息:http ://eu.battle.net/wow/en/character/uldaman/Dus/statistic#21:152

该列表包括一个项目“最高 2 人个人评级”,后跟一个数字。这个号码就是我要找的。存储的数字到底在哪里,我如何获得它?

提前致谢。

4

2 回答 2

1

我正在考虑您正在使用 jQuery:

$('#cat-152 dt').filter(function() { return $(this).text() == "Highest 2 man personal rating" }).siblings('dd').text()
于 2013-07-01T19:13:17.980 回答
0
var http = require('http');
var options = {
    host: 'eu.battle.net',
    path: '/wow/en/character/uldaman/Dus/statistic/152'
};

var count = 0;

http.get(options, function(res) {

    var data = "";

    res.on('data', function (chunk) {
        data += chunk;
    });

    res.on('end', function(){
       var d = data;
       var payload = d.toString();
       var finder = "<dt>Highest 2 man team rating</dt><dd>";
       var indexOfHighest2Man = payload.indexOf(finder);
       var indexOfClosingDD = payload.indexOf("</dd>", indexOfHighest2Man);

       var count = payload.substr(indexOfHighest2Man,  indexOfClosingDD - indexOfHighest2Man);
       count = count.replace(/\s/g, "");
       count = count.replace("<dt>Highest2manteamrating</dt><dd>", "");

       //***************** Here is the answer *******************
       console.log('Highest 2 man rating ',count);
       //********************************************************
    })


}).on('error', function(e) {
        console.log('ERROR: ' + e.message);
    });
于 2013-07-01T23:21:51.563 回答