Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
ruhullalam
14,500 Pointsweb scraper project
On the guide it says choose 2 packages from NPM but all the guides have 3,
request, cheerio and then some parser
Are we allowed to use more than 2?
3 Answers
Thomas Nilsen
14,957 PointsI don't know.
But what I do know, is when I helped another person solve this some time ago, I didn't have two use more than 2 npm-packages (request and cheerio)
ruhullalam
14,500 PointsOk Thanks Thomas, I'll have a go with the two.
Thomas Nilsen
14,957 PointsI would do something like this:
//This in built in to node
var fs = require('fs');
//Here is the part of my code I would change a little bit:
getAllShirtDetailsAsync()
.then(function(data) {
console.log(data);
fs.writeFile('./prices.csv', JSON.stringify(data, null, 2), 'utf-8', err => {
if(err) {
console.log(err.message);
} else {
console.log('CSV-file was successfully created');
}
});
})
.catch(function(err) {
console.log(err);
});
ruhullalam
14,500 Pointsruhullalam
14,500 PointsI cannot figure out how to turn into CSV from just using native and the two modules you've suggested. I've seen in a previous thread where you've put up code for this program but you did state you hadn't formatted it to a csv file.
https://teamtreehouse.com/community/how-do-i-even-begin-to-think-about-scraping-a-site-we-were-not-taught-how-to-do-this
Have you managed this now?