Skip to content

Instantly share code, notes, and snippets.

@clonn
Created October 16, 2017 10:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save clonn/3467c6ec411a5179f7be7c9894e1c591 to your computer and use it in GitHub Desktop.
Save clonn/3467c6ec411a5179f7be7c9894e1c591 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