DEPRECATED: Gramedia has a completely new layout based on React, so this module can't be used anymore.
Umanohone is a module to query information about Gramedia products. It works by scraping the page available at Gramedia store page.
Until Gramedia has an official API for use, this should do.
Install with npm:
$ npm install umanohone
Then use the module:
import umanohone from 'umanohone'
const options = {name: 'grey-jingga-days-of-violet'}
const result = await umanohone(options)
The URL page slug (http://www.gramedia.com/{name}.html
).
On a successful scraping, Umanohone will return an object with these properties:
url
: the Gramedia page URL containing the productimage
: a URL to the product image; can benull
if no product image is availabletitle
: the display-friendly product namedescription
: the product descriptionprice
: the regular product price (without any discount applied)discount
: the object describing any discount if available,null
otherwiseprice
: the price with discount applied as written on the page (not calculated)percentage
: number of discount percentage (e.g.15
for 15% discount)
status
: the product availability (currently eitherin_stock
orout_stock
)preorder
:true
if the product is available as preorder,false
otherwisedetails
: an array of objects that corresponds to the table available at "Product Details" section in the page
On failure, Umanohone will throw an Error
object containing message
(human-friendly error message) and code
. The code
value is one of these possible values:
UMA_NOENT
: no Gramedia page with the providedname
.UMA_UNKNOWN
: unknown error occured.UMA_OUTDATED
: failed to find the required data in the page, usually because the page layout has changed.
If you encountered UMA_UNKNOWN
or UMA_OUTDATED
, please create an issue in the GitHub issues page.
{
name: 'grey-jingga-days-of-violet'
}
{
"url": "http://www.gramedia.com/grey-jingga-days-of-violet.html",
"image": "//wpc.21684.lambdacdn.net/.../grey-dan-jingga---days-of-violet.jpg",
"title": "Grey & Jingga - Days of Violet",
"description": "\"Kisah ini adalah tentang dirinya.\nTentang hari-harinya ... dengan keceriaan.\"",
"price": 35000,
"discount": {
"price": 29750,
"percentage": 15
},
"availability": "in_stock",
"preorder": false,
"details": [
{
"key": "Publisher",
"value": "M&C!"
},
{
"key": "Cover Type",
"value": "SOFT COVER"
}
]
}
{
name: 'neon-genesis-evangelion-13'
}
{
"url": "http://www.gramedia.com/neon-genesis-evangelion-13.html",
"image": "//wpc.21684.lambdacdn.net/.../202956800_xl.jpg",
"title": "Neon Genesis Evangelion 13",
"description": "",
"price": 22500,
"discount": {
"price": 19125,
"percentage": 15
},
"availability": "out_stock",
"preorder": false,
"details": [
{
"key": "Publisher",
"value": "KADOKAWA SHOTEN"
},
{
"key": "Estimated Weight",
"value": "0.15 kg"
},
{
"key": "Publish Date",
"value": "Nov 29, 2013"
}
]
}
The values provided in details
are not uniform between pages, so you should not rely on these values. All values are provided as strings without any processing.
This project follows semver.
However, since Gramedia might changes their website without notice and breaking the scraper, you should always use the latest version available.
Major changes will only be issued if I really have to remove or change a property field.
Feel free to contribute on this module! Help is currently required on:
- additional tests
- scraping on non-book pages (e.g. mobile phones, stationery)
If you prefer working not on the codes, you can also help on other things such as proofreading this documentation, suggesting tests, or checking the Gramedia pages for improvements.
In addition, if you are someone working with or in Gramedia, please ask your superiors to create an API for Gramedia :)
"Umanohone" is the name of a certain fictional book store.
Licensed under MIT License.