Created
March 21, 2018 03:29
-
-
Save tmcw/45c67b9b2d5d76be9ef47b9e65fa6cdf to your computer and use it in GitHub Desktop.
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
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