wintr-amazon-scraper
Version:
Amazon data scraper using Wintr API
70 lines (66 loc) • 3.02 kB
JavaScript
const { constants } = require('wintr')
const { fractionatedPriceSchema } = require('./_commons')
/**
* Wintr output schema for category page
*/
const categoryProductListItemSchema = Object.assign({}, fractionatedPriceSchema, {
title: {
[]: '.octopus-pc-asin-title span',
[]: '*text*',
[]: [
constants.OUTPUT_SCHEMA_MODIFIERS.TRIM_RESULT
]
},
image: {
[]: 'img',
[]: '*html*'
},
link: {
[]: 'a.octopus-pc-item-link',
[]: 'href'
}
})
const extractionSchemaForCategoryPage = {
featuredCategories: {
[]: '.octopus-pc-category-card-v2-item',
[]: {
// @fixme: Image src does not get extracted properly. Possibly lazy-loading related
image: {
[]: 'img',
[]: 'src'
},
title: {
[]: '.a-section octopus-pc-category-card-v2-category-title span',
[]: '*text*',
[]: [
constants.OUTPUT_SCHEMA_MODIFIERS.TRIM_RESULT
]
},
link: {
[]: '.a-link-normal octopus-pc-category-card-v2-category-link',
[]: 'href'
}
}
},
bestSellers: {
[]: '.octopus-best-seller-card ul > li',
[]: categoryProductListItemSchema
},
topRated: {
[]: '.octopus-top-rated-card ul > li',
[]: categoryProductListItemSchema
},
mostWishedFor: {
[]: '.octopus-most-wished-for-card ul > li',
[]: categoryProductListItemSchema
},
mostGifted: {
[]: '.octopus-most-gifted-card ul > li',
[]: categoryProductListItemSchema
},
hotNew: {
[]: '.octopus-new-release-card ul > li',
[]: categoryProductListItemSchema
}
}
module.exports = { extractionSchemaForCategoryPage }