Skip to content

Instantly share code, notes, and snippets.

@lamb-mei
Forked from clonn/scapeCostco.js
Created October 16, 2017 10:37
Show Gist options
  • Save lamb-mei/e57cc0a4764c3a8cdaf533aef318f4f0 to your computer and use it in GitHub Desktop.
Save lamb-mei/e57cc0a4764c3a8cdaf533aef318f4f0 to your computer and use it in GitHub Desktop.
擷取 costco 商品資料,如果商品沒有貨, result 的結果會是已售完
var request = require('request');
var cheerio = require('cheerio');
var url = 'https://www.costco.com.tw/Baby-Care-Kids-Toys/Toys/Infant-%26-Preschool/VTech-Sit-To-Stand-Ultimate-Alphabet-Train/p/105123';
request(url, function(err, res, body){
var $ = cheerio.load(body);
var result = $('.stock-status').text().trim();
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment