Skip to content

Instantly share code, notes, and snippets.

@huybui02
Last active June 3, 2017 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huybui02/24891f6683e10942174b29d902b90097 to your computer and use it in GitHub Desktop.
Save huybui02/24891f6683e10942174b29d902b90097 to your computer and use it in GitHub Desktop.
wh
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