Untitled

mail@pastecode.io avatar
unknown
javascript
2 months ago
1.6 kB
8
Indexable
Never
let userCounts = {};

const desiredUsernames = ["Dostupnost", "Letovo", "montrealmafia", "shesh💀", "Artcore", "майкл оптика", "mamon",
                          "Hammer", "дом моды dagestana", "fomkin", "KYMbIC", "palka2006", "Kingsman.", "PaFFoS", "Januarsky", "StasisС", "amoxіl", "savosky", "BigFloppa", "2rbina 2rista", "nalerman", "sano.",
                          "blonde in law", "MillioS", ""];

async function processPage(pageNumber) {
  const url = `https://forum.gambit-rp.ru/forums/112/page-${pageNumber}`;
  const response = await fetch(url);
  const html = await response.text();
  const parser = new DOMParser();
  const doc = parser.parseFromString(html, 'text/html');
  const blocks = doc.querySelectorAll('.structItem-cell');

  blocks.forEach(block => {
    const usernameElement = block.querySelector('.username');
    if (usernameElement) {
      const username = usernameElement.textContent.trim();
      const userId = usernameElement.getAttribute('data-user-id');

      //if (desiredUsernames.includes(username)) {
        userCounts[username] = userCounts[username] || { count: 0, userIds: new Set() };
        userCounts[username].count++;
        userCounts[username].userIds.add(userId);
      //}
    }
  });
}

const totalPages = 18;
for (let i = totalPages; i >= 1; i--) {
  await processPage(i);
}

for (const username in userCounts) {
  if (userCounts.hasOwnProperty(username)) {
    console.log(`${Array.from(userCounts[username].userIds).join(', ')} ${userCounts[username].count}`);
  }
}
Leave a Comment