Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created March 21, 2018 03:29
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 tmcw/45c67b9b2d5d76be9ef47b9e65fa6cdf to your computer and use it in GitHub Desktop.
Save tmcw/45c67b9b2d5d76be9ef47b9e65fa6cdf to your computer and use it in GitHub Desktop.
async get(type, id) {
const redirectedUrl = await new Promise(resolve => {
https.get(`${this.base}/${type}/${id}`, res => {
resolve(res.headers.location);
});
});
const microdata = wae().parse(await getText(redirectedUrl));
// TODO: how else could this data be shaped?
return {
isbn: _.property(["rdfa", 'ProductModel', 0, 'schema:isbn'])(microdata),
oclc: _.property(["rdfa", 'CreativeWork', 0, 'library:oclcnum'])(microdata)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment