|
|
|
|
@ -10,6 +10,9 @@ module.exports = {
|
|
|
|
|
const sellerSelector = '.ux-seller-section__item--seller > a:nth-child(1) > span:nth-child(1)';
|
|
|
|
|
const alternateSellerSelector = 'html.font-marketsans body.vi-body.en-US.gh-flex div.vi-evo div.main-container div.vim.x-vi-evo-main-container.template-evo-avip div#CenterPanel.center-panel-container.vi-mast div.vi-grid div.vi-mast__grid div#RightSummaryPanel.right-summary-panel-container.vi-mast__col-right div#mainContent.vim.x-evo-atf-right-river div.vim.d-vi-evo-region div.vim.x-sellercard-atf_main.mar-t-12 div.vim.x-sellercard-atf div.x-sellercard-atf__info div.x-sellercard-atf__info__about-seller a.ux-action span.ux-textspans.ux-textspans--BOLD';
|
|
|
|
|
const descriptionSelectr = '#desc_ifr';
|
|
|
|
|
|
|
|
|
|
const filmstripSelector = '.filmstrip';
|
|
|
|
|
const filmstripThumbnailSelector = '.ux-image-grid-item > img';
|
|
|
|
|
//page is considered loaded
|
|
|
|
|
//get the seller to see if we can tell what layout its using
|
|
|
|
|
|
|
|
|
|
@ -47,6 +50,21 @@ module.exports = {
|
|
|
|
|
}));
|
|
|
|
|
sources = sourcesFromThumbnailGallery;
|
|
|
|
|
}
|
|
|
|
|
log.info(`Found ${sources.length} images through thumbnails location as backup....`);
|
|
|
|
|
log.info('Checking filmstrip...');
|
|
|
|
|
const hasFilmstrip = !!(await page.$(filmstripSelector));
|
|
|
|
|
if(hasFilmstrip) {
|
|
|
|
|
const carouselItems = await page.$$(filmstripThumbnailSelector);
|
|
|
|
|
const sourcesFromThumbnailGallery = await Promise.all(carouselItems.map(async carouselItem => {
|
|
|
|
|
const src = await page.evaluate(el => el.getAttribute('src'), carouselItem);
|
|
|
|
|
return { url: convertThumbnailUrlToFullSize(src) };
|
|
|
|
|
}));
|
|
|
|
|
sources.push(...sourcesFromThumbnailGallery.filter((o => !!o.url)));
|
|
|
|
|
}
|
|
|
|
|
log.info(`Found ${sources.length} images through filmstrip location as backup....`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info('Performing autoscroll')
|
|
|
|
|
await autoScroll(page); //auto scroll to trigger loading of description iframe
|
|
|
|
|
log.info('autoscroll complete');
|
|
|
|
|
@ -72,7 +90,7 @@ module.exports = {
|
|
|
|
|
return sources;
|
|
|
|
|
}
|
|
|
|
|
const hasSectionedImages = !!(await page.$('main.content'));
|
|
|
|
|
log.info(hasSectionedImages);
|
|
|
|
|
log.info(`hasSectionedImages: ${hasSectionedImages}`);
|
|
|
|
|
if(hasSectionedImages) {
|
|
|
|
|
const imageSelector = 'main.content > div > div > div > a > img';
|
|
|
|
|
const images = await page.$$(imageSelector);
|
|
|
|
|
@ -95,6 +113,7 @@ module.exports = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function convertThumbnailUrlToFullSize(url) {
|
|
|
|
|
if(!url) return null;
|
|
|
|
|
const baseName = url.substring(url.lastIndexOf('/') + 1)
|
|
|
|
|
const basePath = url.replace(baseName, '');
|
|
|
|
|
return `${basePath}s-l1600.jpg`;
|
|
|
|
|
|