Last active
June 3, 2017 18:28
-
-
Save huybui02/24891f6683e10942174b29d902b90097 to your computer and use it in GitHub Desktop.
wh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var linkdt = "http://www.lazada.vn/dien-thoai-di-dong/?itemperpage=120&sort=popularity&viewType=listView&fs=1"; | |
var a = laySotrang(linkdt); | |
console.log(a); | |
// Get pager | |
function laySotrang(urlTrang){ | |
var kq; | |
new Promise(function (resolve, reject) { | |
request(urlTrang, function (error, res, body) { | |
if (error) { | |
return reject(error); | |
} else { | |
var $ = cheerio.load(body); | |
var ks = $('.c-paging__link').last().text(); | |
kq = parseInt(ks); | |
//console.log(kq); | |
return resolve(kq); | |
} | |
}); | |
}).catch(function (err) { | |
console.log("Co loi xay ra: ", err); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment