Skip to content

Instantly share code, notes, and snippets.

@fuka
Last active June 7, 2018 12:32
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 fuka/a19a13aee42738b36a52e681ad5f4ce2 to your computer and use it in GitHub Desktop.
Save fuka/a19a13aee42738b36a52e681ad5f4ce2 to your computer and use it in GitHub Desktop.
amazon.co.jpのASINから商品名を取得する
const client = require('cheerio-httpcli');
const ids = [
'B06XDFJJRS',
'B00IOY56P8',
'B01FIG3SMC',
'B0186FEWLS',
];
ids.forEach(function(value) {
fetchTitle(value);
});
function fetchTitle(id) {
client.fetch('https://www.amazon.co.jp/dp/' + id, null, function (err, $, res, body) {
const title = $('span#productTitle').text().trim();
console.log(id + ', ' + title);
});
}
{
"name": "playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"cheerio-httpcli": "^0.7.3",
"npm": "^6.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment