async function _scrapeKnivesPage(url) {
  const knives = { yellow: [] };

  console.log(`Scraping knives/gloves at ${url}`);

  // Load page into Cheerio
  const html = await _getHtml(url);
  const $ = cheerio.load(html);

  // Get URLs of additional pages
  const pageUrls = [
    ...new Set(
      $('div .pagination-nomargin > ul > li > a')
        .map((i, result) => $(result).attr('href'))
        .toArray()
    ),
  ];

  // Find element (row) containing result boxes
  const resultBoxRow = $('div .row').has('div > div .result-box');

  // Get HTML of other pages
  for (const pageUrl of pageUrls) {
    const pageHtml = await _getHtml(url);
    const page$ = cheerio.load(pageHtml);
    const pageResultBoxRow = page$('div .row ').has('div > div .result-box');

    // Merge result boxes with original result boxes
    resultBoxRow.append(pageResultBoxRow.children());
  }

  // Extract knives data
  await _extractWeaponData($, knives, 'yellow', true);

  return knives;
}
/**
 * Extract all knives at the provided URL. Also works for gloves.
 * @param {string} url - URL to scrape
 * @returns {Promise<import('../typedefs/container').ContainerKnifeData>} knives in container
 */
Extract all knives at the provided URL. Also works for gloves.
@param {string} url - URL to scrape
@returns {Promise} knives in container
Extract all knives at the provided URL . Also works for gloves . @param { string } url - URL to scrape @returns { Promise } knives in container
async function _scrapeKnivesPage(url) {
  const knives = { yellow: [] };
  console.log(`Scraping knives/gloves at ${url}`);
  const html = await _getHtml(url);
  const $ = cheerio.load(html);
  const pageUrls = [
    ...new Set(
      $('div .pagination-nomargin > ul > li > a')
        .map((i, result) => $(result).attr('href'))
        .toArray()
    ),
  ];
  const resultBoxRow = $('div .row').has('div > div .result-box');
  for (const pageUrl of pageUrls) {
    const pageHtml = await _getHtml(url);
    const page$ = cheerio.load(pageHtml);
    const pageResultBoxRow = page$('div .row ').has('div > div .result-box');
    resultBoxRow.append(pageResultBoxRow.children());
  }
  await _extractWeaponData($, knives, 'yellow', true);
  return knives;
}
async function _scrapeKnivesPage ( url ) { const knives = { yellow : [ ] } ; console . log ( ` ${ url } ` ) ; const html = await _getHtml ( url ) ; const $ = cheerio . load ( html ) ; const pageUrls = [ ... new Set ( $ ( 'div .pagination-nomargin > ul > li > a' ) . map ( ( i , result ) => $ ( result ) . attr ( 'href' ) ) . toArray ( ) ) , ] ; const resultBoxRow = $ ( 'div .row' ) . has ( 'div > div .result-box' ) ; for ( const pageUrl of pageUrls ) { const pageHtml = await _getHtml ( url ) ; const page$ = cheerio . load ( pageHtml ) ; const pageResultBoxRow = page$ ( 'div .row ' ) . has ( 'div > div .result-box' ) ; resultBoxRow . append ( pageResultBoxRow . children ( ) ) ; } await _extractWeaponData ( $ , knives , 'yellow' , true ) ; return knives ; }
Extract all knives at the provided URL.
Extract all knives at the provided URL .
// Load page into Cheerio // Get URLs of additional pages // Find element (row) containing result boxes // Get HTML of other pages // Merge result boxes with original result boxes // Extract knives data