wintr-amazon-scraper
Version:
Amazon data scraper using Wintr API
53 lines (50 loc) • 2.14 kB
JavaScript
const { constants } = require('wintr')
const { fractionatedPriceSchema } = require('./_commons')
/**
* Wintr output schema for search page
*/
const extractionSchemaForSearchPage = {
hasNextPage: {
[]: 'body',
[]: {
link: {
[]: '.a-pagination .a-selected + .a-normal a',
[]: 'href'
}
}
},
searchResult: {
[]: '.s-result-list.s-search-results span[data-cel-widget="SEARCH_RESULTS-SEARCH_RESULTS"]',
[]: Object.assign({}, fractionatedPriceSchema, {
title: {
[]: 'h2 span',
[]: '*text*',
[]: [
constants.OUTPUT_SCHEMA_MODIFIERS.TRIM_RESULT
]
},
image: {
[]: '[data-component-type="s-product-image"] img',
[]: 'src'
},
rating: {
[]: '[aria-label$="out of 5 stars"]',
[]: 'aria-label',
[]: [
{
[]: ' out of 5 stars',
[]: ''
}
],
[]: [
constants.OUTPUT_SCHEMA_MODIFIERS.TO_NUMBER
]
},
link: {
[]: '[data-component-type="s-product-image"] a',
[]: 'href'
}
})
}
}
module.exports = { extractionSchemaForSearchPage }