const https= require('https'); const cheerio = require('cheerio'); const http= require('http'); async function getHttp(url){ return new Promise((resolve, reject) => { http.get(url, (res) => { let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }) res.on('end', async () => { resolve(rawData); }); }) }) } ///Xu ly http://thuocgiaotannha.com async function parseHomePageGiaoThuocTanNha(){ let htmlPage= await getHttp('http://thuocgiaotannha.com'); const $ =await cheerio.load(htmlPage); const Drugs =$('#menu_page > ul > li:nth-child(2) > ul > li'); // console.log(Drugs.length); // console.log(Drugs[0]); const drugList = []; for( let i=0; i< Drugs.length; i++) { drugList.push({ name: Drugs[i].children[1].attribs.title, link: Drugs[i].children[1].attribs.href }) } return drugList; } async function listURLOf(){ let htmlPage=await getHttp(''); } async function main() { var list=await parseHomePageGiaoThuocTanNha(); console.log(list); } main();