I'm making a node js bot that need to get data grom indiexpo, by accessing the rank and the level of a user, that by a normal person can be accesed my going to https://www.indiexpo.net/en/users/[user-name] (ex. https://www.indiexpo.net/en/users/freank ), the website it self desn't have any api that you can use to acses it via code so i think i will have to extract the numbers from the html file thta is generated when gong to those links.

I've already tried cheerio, but because of the complex structure of the website and the non dinstinction by name of the interessed object it makes my life very difficult.

i don't have any code yet . . . 

in the case of the example user thta i've linked the values returned shoude be:

level: 12
rank: 14

thanks for the help

1 Answers

1
RishiC On Best Solutions

You can use the node module request for it and then do some String manipulation. I tested out this code and it gave me the correct level and rank as mentioned in the question

var request = require('request');
request('https://www.indiexpo.net/en/users/freank', function(error,response,body){
    var L_count = body.indexOf("Level: ")+7
    var R_count = body.indexOf("Rank: ")+6
    var level = ""
    var rank = ""
    while(!isNaN(body.charAt(L_count))){
        level+=body.charAt(L_count);
        L_count ++;
    }
    while(!isNaN(body.charAt(R_count))){
        rank+=body.charAt(R_count)
        R_count ++
    }
    console.log(level);
    console.log(rank);
})

I don't know if there is a more efficient way to do it, this is the most efficient one I could think of which used string manipulation

(PS: Note that body here is the html code of the page)