Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better scraping #16

Merged
merged 2 commits into from
Mar 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Initial implementation of the Coolmod scraper
  • Loading branch information
RodrigoTomeES committed Mar 20, 2021
commit 3c3fd7afd10be55109bd818057475abd75daf7f7
22 changes: 22 additions & 0 deletions src/scripts/coolmod/scrape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const scrape = require('scrape-it')

module.exports = async ({ link }) =>
(
await scrape(link, {
price: {
selector: 'span[class="text-price-total"]',
how: x => Number(x.textContent.trim())
},
stock: {
selector: '.button-buy'
},
image: {
selector: 'div.container-main-image a img',
attr: 'src'
},
name: {
selector: '.product-first-part',
convert: x => x.textContent.trim()
}
})
).data