Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hmv-scraper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmv-scraper

Scraper that searches products on the Canadian HMV online store https://www.hmv.ca.

  • 1.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

hmv-scraper

Dependency Status TravisCI Status

Scraper that searches products on the Canadian HMV store hmv.ca.

install

Using npm.

npm install hmv-scraper

usage

new HmvScraper(onProductError)

Optional param onProductError is a function that will be called when a product unexpectedly fail the validation. It takes respectively, the product, an array of AJV Error, and a string that represents the errors.

var HmvScraper = require('hmv-scraper');
var onProductError = function (product, errors, errorsText) {
  console.log('Product failed validation: ' + errorsText);
  console.log(product);
};
var hmv = new HmvScraper(onProductError);

// or

var HmvScraper = require('hmv-scraper');
var hmv = new HmvScraper();
searchByKeyword(query, callback(error, results))

Search products by keyword.

hmv.searchByKeyword({
  query: 'James Bond'  
}, function(error, results) {
  if (error) {
    console.log(error);
  } else {
    console.log(results);
  }
});
searchByArtist(query, callback(error, results))

Search products by artist.

hmv.searchByArtist({
  query: 'Céline Dion',
  sort: 'Bestselling',
  filter: 'All',
  page: 3
}, function(error, results) {
  if (error) {
    console.log(error);
  } else {
    console.log(results);
  }
});
param query
NameDescriptionAccepted valuesDefault valueRequired
queryThe keyword or the artist you search.StringYes
pageThe page of result that you want.Integer1No
filterThe group in which you want to search.'All', 'CD', 'Vinyl', 'DVD', 'Bluray', '3dBluray', 'Headphones', 'GiftsCollect', 'Apparel''All'No
sortThe order in which the products should sort.'Bestselling', 'Date of release', 'Price: Low to High', 'Price: High to Low', 'Alphabetical: A to Z', 'Alphabetical: Z to A''Bestselling'No
param callback(error, products)

Function that is called when the request is done or when there is an error.

product

The structure of a product is described below, for more details check the product JSON schema.

NameTypeDescriptionAlways present
idIntegerIdYes
skuIntegerSKUYes
nameStringName of the productYes
priceInCentsIntegerPrice in cents in Canadian dollarYes
categoryStringThe category ('Music', 'Film', 'Apparel', 'Headphones', 'Gift')Yes
kindStringThe kind of product or its format if the category is 'Music' or 'Film'Yes
availableBooleanIf the product is available onlineYes
urlStringUrl of the product in the storeYes
reservationUrlStringThe reservation URL to find a store and reserve the productYes
catalogueStringCatalogue number or serial numberNo
promotionStringThe promotionsNo
supplierStringThe supplier nameNo
smallImageUrlStringSmall image URLNo
mediumImageUrlStringMedium image URLNo
largeImageUrlStringLarge image URLNo
releaseDateStringThe released date in ISO 8601 date formatOnly if category is 'Music' or 'Film'
artistStringThe artist of the productOnly if category is 'Music'

Example:

{
  id: 72201,
  sku: 246337,
  name: 'NEW DAY HAS COME',
  priceInCents: 1500,
  category: 'Music',
  kind: 'CD',
  available: true,
  url: 'https://www.hmv.ca/en/Search/Details?sku=246337',
  reservationUrl: 'https://www.hmv.ca/en/Stores?reserve=true&id=72201',
  catalogue: 'CK86400',
  supplier: 'COLUMBIA',
  smallImageUrl: 'https://www.hmv.ca/images/Music/75/44/4443/444344.jpg',
  mediumImageUrl: 'https://www.hmv.ca/images/Music/170/44/4443/444344.jpg',
  largeImageUrl: 'https://www.hmv.ca/images/Music/450/44/4443/444344.jpg',
  artist: 'CELINE DION',
  releaseDate: '2002-03-26'
}

Contributing

Contribution is welcome! Open an issue first.

test

npm test

license

MIT

Keywords

FAQs

Package last updated on 13 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc