qrtzcode
HomeDocsAPILeaderboardChangelog
Contribute
Docs

qrtzcode

Kumpulan gist & snippet pribadi — anime, AI tools, scraper, dan randomness.

Navigate

HomeDocsAPI Reference

Links

© 2026 qrtz. All snippets welcome.

ESC

Navigate

Links

Anime

alqanime

scraper alqanime lengkap:p.

Creator

qrtz

Language

javascript

Views

79

Copies

13

Base

https://alqanime.net

Updated

18 Agu 2026

#anime

Code

7913
alqanime.js
const axios = require('axios');
const cheerio = require('cheerio');
const fs = require('fs');

const USER_AGENTS = [
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0',
  'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0',
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15',
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
  'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
];

function getRandomUserAgent() {
  return USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)];
}

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function fetchPage(url, retries = 3) {
  for (let i = 0; i < retries; i++) {
    try {
      const response = await axios.get(url, {
        headers: {
          'User-Agent': getRandomUserAgent(),
          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
          'Accept-Language': 'en-US,en;q=0.5',
          'Accept-Encoding': 'gzip, deflate, br',
          'Connection': 'keep-alive',
          'Upgrade-Insecure-Requests': '1',
          'Sec-Fetch-Dest': 'document',
          'Sec-Fetch-Mode': 'navigate',
          'Sec-Fetch-Site': 'none',
          'Sec-Fetch-User': '?1',
          'Cache-Control': 'max-age=0',
        },
        timeout: 30000,
      });
      await sleep(500 + Math.random() * 1000);
      return response.data;
    } catch (e) {
      if (i === retries - 1) throw e;
      await sleep(1000 * (i + 1));
    }
  }
}

function parseListPage(html) {
  const $ = cheerio.load(html);
  const items = [];
  $('article.bs').each((i, el) => {
    const $el = $(el);
    const title = $el.find('.eggtitle').text().trim() || $el.find('.tt .ntitle').text().trim() || '';
    const url = $el.find('a[itemprop="url"]').attr('href') || '';
    const thumbnail = $el.find('img.ts-post-image').attr('src') || '';
    const status = $el.find('.status').text().trim() || 'Ongoing';
    const type = $el.find('.eggtype').text().trim() || $el.find('.typez').text().trim() || '';
    const ratingScore = $el.find('.numscore').text().trim() || '';
    const ratingPercent = $el.find('.rtb span').attr('style')?.match(/width:([^%]+)%/)?.[1] || '';
    const episode = $el.find('.eggepisode').text().trim() || $el.find('.ntitle').text().match(/Episode\s*\(?(\d+)\)?/)?.[1] || '';
    if (title || url) {
      items.push({ title, url, thumbnail, status, type, ratingScore, ratingPercent, episode });
    }
  });
  return items;
}

async function scrapeHome(page = 1) {
  const url = page === 1 ? 'https://alqanime.net/' : `https://alqanime.net/page/${page}/`;
  const html = await fetchPage(url);
  const data = parseListPage(html);
  return { creator: 'rynaqrtz', halaman: 'home', page, data };
}

async function scrapePopular(page = 1) {
  const url = page === 1 ? 'https://alqanime.net/popular/' : `https://alqanime.net/popular/page/${page}/`;
  const html = await fetchPage(url);
  const data = parseListPage(html);
  return { creator: 'rynaqrtz', halaman: 'popular', page, data };
}

async function scrapeTag(tag, page = 1) {
  const url = page === 1 ? `https://alqanime.net/tag/${tag}/` : `https://alqanime.net/tag/${tag}/page/${page}/`;
  const html = await fetchPage(url);
  const data = parseListPage(html);
  return { creator: 'rynaqrtz', halaman: 'tag', page, data, tag };
}

async function scrapeJadwal() {
  const url = 'https://alqanime.net/jadwal-rilis/';
  const html = await fetchPage(url);
  const $ = cheerio.load(html);
  const result = {};
  $('.bixbox').each((i, el) => {
    const $el = $(el);
    const day = $el.find('.releases h3').text().trim();
    const items = [];
    $el.find('.listupd article.bs').each((j, art) => {
      const $art = $(art);
      const title = $art.find('.eggtitle').text().trim() || $art.find('.tt .ntitle').text().trim() || '';
      const url = $art.find('a[itemprop="url"]').attr('href') || '';
      const thumbnail = $art.find('img.ts-post-image').attr('src') || '';
      const type = $art.find('.eggtype').text().trim() || $art.find('.typez').text().trim() || '';
      const episode = $art.find('.eggepisode').text().trim() || $art.find('.ntitle').text().match(/Episode\s*\(?(\d+)\)?/)?.[1] || $art.find('a[itemprop="url"]').attr('title')?.match(/Episode\s*\(?(\d+)\)?/)?.[1] || '';
      items.push({ title, url, thumbnail, type, episode });
    });
    if (day) result[day] = items;
  });
  return { creator: 'rynaqrtz', halaman: 'jadwal', data: result };
}

async function scrapeGenre() {
  const url = 'https://alqanime.net/genre/';
  const html = await fetchPage(url);
  const $ = cheerio.load(html);
  const genres = [];
  $('.blix ul li a').each((i, el) => {
    genres.push($(el).text().trim());
  });
  return { creator: 'rynaqrtz', halaman: 'genre', data: genres };
}

async function scrapeDetail(slugOrUrl) {
  let slug = slugOrUrl;
  if (slugOrUrl.startsWith('http')) {
    const urlObj = new URL(slugOrUrl);
    const pathParts = urlObj.pathname.split('/').filter(p => p);
    slug = pathParts[pathParts.length - 1] || pathParts[0];
  }
  const url = `https://alqanime.net/${slug}/`;
  const html = await fetchPage(url);
  const $ = cheerio.load(html);
  const title = $('.infox h1').text().trim() || '';
  const thumbnail = $('.thumb img').attr('src') || '';
  const sinopsis = $('.entry-content p').text().trim() || '';
  const info = {};
  $('.spe span').each((i, el) => {
    const text = $(el).text().trim();
    const parts = text.split(':');
    if (parts.length >= 2) {
      const key = parts[0].trim();
      const value = parts.slice(1).join(':').trim();
      info[key] = value;
    }
  });
  const genres = [];
  $('.genxed a').each((i, el) => {
    genres.push($(el).text().trim());
  });
  const casts = [];
  $('.casts').each((i, el) => {
    casts.push($(el).text().trim());
  });
  const episodes = [];
  $('.soraddl').each((i, el) => {
    const $el = $(el);
    const titleEp = $el.find('.sorattl h3').text().trim() || '';
    const resolutions = [];
    $el.find('table tr').each((j, row) => {
      const $row = $(row);
      const resolution = $row.find('.reso .res').text().trim() || '';
      const links = [];
      $row.find('.slink a').each((k, a) => {
        const href = $(a).attr('href');
        const label = $(a).text().trim();
        if (href) links.push({ label, url: href });
      });
      if (resolution || links.length) {
        resolutions.push({ resolution, links });
      }
    });
    if (titleEp || resolutions.length) {
      episodes.push({ title: titleEp, resolutions });
    }
  });
  const data = { title, thumbnail, sinopsis, info, genres, casts, episodes };
  return { creator: 'rynaqrtz', halaman: 'detail', data };
}

async function scrapeAdvancedSearch(filters = {}, page = 1) {
  const base = 'https://alqanime.net/advanced-search/';
  const query = new URLSearchParams();
  if (filters.genre) filters.genre.forEach(g => query.append('genre[]', g));
  if (filters.season) filters.season.forEach(s => query.append('season[]', s));
  if (filters.studio) filters.studio.forEach(s => query.append('studio[]', s));
  if (filters.status) query.append('status', filters.status);
  if (filters.type) filters.type.forEach(t => query.append('type[]', t));
  if (filters.order) query.append('order', filters.order);
  const queryString = query.toString();
  const url = page === 1
    ? base + (queryString ? '?' + queryString : '')
    : base + `page/${page}/` + (queryString ? '?' + queryString : '');
  const html = await fetchPage(url);
  const data = parseListPage(html);
  return { creator: 'rynaqrtz', halaman: 'search', page, filters, data };
}

function printJSON(obj) {
  console.log(JSON.stringify(obj, null, 2));
}

function parseArgs() {
  const args = process.argv.slice(2);
  if (args.length === 0) {
    console.log('Usage:');
    console.log('  node alqanime.js detail <slug or url>');
    console.log('  node alqanime.js home [page]');
    console.log('  node alqanime.js popular [page]');
    console.log('  node alqanime.js tag <tag> [page]');
    console.log('  node alqanime.js jadwal');
    console.log('  node alqanime.js genre');
    console.log('  node alqanime.js daftar [--genre action,comedy] [--season spring-2026] [--studio mappa] [--status ongoing] [--type tv,movie] [--order rating] [--page 2]');
    return;
  }
  const command = args[0];
  if (command === 'detail') {
    const input = args[1];
    if (!input) { console.error('Slug or URL required'); return; }
    scrapeDetail(input).then(printJSON).catch(e => console.error(e.message));
  } else if (command === 'home') {
    const page = parseInt(args[1]) || 1;
    scrapeHome(page).then(printJSON).catch(e => console.error(e.message));
  } else if (command === 'popular') {
    const page = parseInt(args[1]) || 1;
    scrapePopular(page).then(printJSON).catch(e => console.error(e.message));
  } else if (command === 'tag') {
    const tag = args[1];
    if (!tag) { console.error('Tag required'); return; }
    const page = parseInt(args[2]) || 1;
    scrapeTag(tag, page).then(printJSON).catch(e => console.error(e.message));
  } else if (command === 'jadwal') {
    scrapeJadwal().then(printJSON).catch(e => console.error(e.message));
  } else if (command === 'genre') {
    scrapeGenre().then(printJSON).catch(e => console.error(e.message));
  } else if (command === 'daftar') {
    const filters = {};
    let page = 1;
    for (let i = 1; i < args.length; i++) {
      const arg = args[i];
      if (arg.startsWith('--')) {
        const key = arg.slice(2);
        const value = args[i + 1];
        if (['genre', 'season', 'studio', 'type'].includes(key)) {
          filters[key] = value.split(',').map(s => s.trim());
        } else if (key === 'status') {
          filters.status = value;
        } else if (key === 'order') {
          filters.order = value;
        } else if (key === 'page') {
          page = parseInt(value) || 1;
        }
        i++;
      }
    }
    scrapeAdvancedSearch(filters, page).then(printJSON).catch(e => console.error(e.message));
  } else {
    console.error(`Unknown command: ${command}`);
  }
}

parseArgs();

Rating

1.0(1)

Gimana snippet ini menurutmu?

</> Embed

Embed ke website / blog

<iframe src="https://qrtzcode.vercel.app/api/embed/anime/alqanime" style="width:100%;height:400px;border:none;border-radius:12px;"></iframe>

Related Snippets

anoboy

semoga bermanfaat^^.

48
17

nimegami

Semoga bermanfaat^^.

46
14

Nonton Anime

yh.

29
10