const http=require('http'); const cheerio=require('cheerio'); http.get( 'http://thuoctot24h.com/tamozi-diet-giam-can-theo-phuong-phap-nhat.html', function(res){ let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }); res.on('end',async () => { const $=await cheerio.load(rawData); //ten thuoc const selecTenSP= $('h1.title-name-product'); var tenSP=selecTenSP[0].children[0].data; //Gia const selecGiaSP=$('span.lb-price.price-main'); var giaSP=selecGiaSP[0].children[0].data; const selec=$('#content > p'); //Cong dung var listCongDung=[]; listCongDung.push(selec[3].children[0].data); listCongDung.push(selec[4].children[0].data); /* kiếm thẻ h2 rồi next tìm thẻ p nếu hết thẻ p thì thôi */ //doi tuong var listDoiTuong=[]; listDoiTuong.push(selec[5].children[0].data); listDoiTuong.push(selec[6].children[0].data); //cach su dung var listCachSuDung=[]; listCachSuDung.push(selec[10].children[0].data); listCachSuDung.push(selec[8].children[0].data); listCachSuDung.push(selec[9].children[0].data); //thong tin san pham var listThongTinSP=[]; listThongTinSP.push(selec[11].children[0].data); listThongTinSP.push(selec[12].children[0].data); listThongTinSP.push(selec[13].children[0].data); listThongTinSP.push(selec[14].children[0].data); //thanh phan var listThanhPhan=[]; const selecTable=$('#content > table > tbody'); for(var j=0;j