Last active
June 7, 2018 12:32
-
-
Save fuka/a19a13aee42738b36a52e681ad5f4ce2 to your computer and use it in GitHub Desktop.
amazon.co.jpのASINから商品名を取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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