Показать сообщение отдельно
  #6 (permalink)  
Старый 06.12.2021, 04:17
Аватар для Aetae
Тлен
Отправить личное сообщение для Aetae Посмотреть профиль Найти все сообщения от Aetae
 
Регистрация: 02.01.2010
Сообщений: 6,491

const axios = require('axios');
const cheerio = require('cheerio');
const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
const util = require('util');
const question = util.promisify(readline.question).bind(readline);

const getHTML = async (url) => {
  const { data } = await axios.get(url)
  return cheerio.load(data)
}

async function questionExample() {
  const userIdInput = await question('Введите ID пользователя: ');
  
  for (let i = 0n; i <= 0n; ++i) {
    let userID = BigInt(userIdInput) + i;
    const $ = await getHTML('https://steamcommunity.com/profiles/' + String(userID));

    //LVL
    let userLvl = $('span.friendPlayerLevelNum').eq(0).text();
    if ((Number(userLvl) === 0)) {
      userLvl = true;
    } else {
      userLvl = false;
    }

    //ONLINE
    let userOnline = $('div.profile_in_game_header').eq(0).text();
    if ((String(userOnline) === 'Currently Online')) {
      userOnline = true;
    } else if ((String(userOnline) === 'Currently In-Game')) {
      userOnline = true;
    } else if ((String(userOnline) === 'In non-Steam game')) {
      userOnline = true;
    } else {
      userOnline = false;
    }

  }
}
questionExample();
__________________
29375, 35
Ответить с цитированием