Skip to content

Instantly share code, notes, and snippets.

@chuanxd
Forked from clonn/scapeCostco.js
Created October 17, 2017 00:52
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 chuanxd/fdfeb9f19a13fa83d8ff83f7c89f892c to your computer and use it in GitHub Desktop.
Save chuanxd/fdfeb9f19a13fa83d8ff83f7c89f892c 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