paperhive / oai-pmh Goto Github PK
View Code? Open in Web Editor NEWOAI-PMH 2.0 harvester module for nodejs
License: GNU General Public License v3.0
OAI-PMH 2.0 harvester module for nodejs
License: GNU General Public License v3.0
I am getting the following error running the sample code.
My Node version is v10.5.0 and npm 6.1.0
(function (exports, require, module, __filename, __dirname) { import { OaiPmh } from 'oai-pmh'
^
SyntaxError: Unexpected token {
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)
In such cases the servers responds with Error: Unexpected status code 403 (expected 200).
./oai-pmh list-records -p oai_dc "http://arca.igc.gulbenkian.pt/oaiextended/request"
Add the following header to every request made:
options.headers = {
'User-Agent': 'request'
};
Can I use an array like: ['cs', 'stat'] to 'set' param when call listRecords function?
From this script
import { OaiPmh } from 'oai-pmh'
async function main () {
const oaiPmh = new OaiPmh('http://www.culturaitalia.it/oaiProviderCI/OAIHandler')
const identifierIterator = oaiPmh.getRecord({
metadataPrefix: 'oai_dc',
identifier:'oai:culturaitalia.it:oai:www.michael-culture.it:pub-it/dcollection/IT-DC-e555496e'
})
for await (const identifier of identifierIterator) {
console.log(identifier)
}
}
main().catch(console.error)
Running the command getRecord I got this error(s)
TypeError: identifierIterator is not async iterable
at main (/Users/matteo/vsProject/OAI-PMH/richiesta_terminale.js:9:34)
at Object. (/Users/matteo/vsProject/OAI-PMH/richiesta_terminale.js:14:1)
at Cl (/Users/matteo/node_modules/esm/esm.js:1:210825)
at Object.run (/Users/matteo/node_modules/esm/esm.js:1:209532)
at Object. (/Users/matteo/vsProject/OAI-PMH/richiesta_terminale.js:1:86)
at Object. (/Users/matteo/node_modules/esm/esm.js:1:223819)
at eu (/Users/matteo/node_modules/esm/esm.js:1:217938)
at /Users/matteo/node_modules/esm/esm.js:1:219136
at ou (/Users/matteo/node_modules/esm/esm.js:1:219372)
at Object.g (/Users/matteo/node_modules/esm/esm.js:1:230080)
(node:23762) UnhandledPromiseRejectionWarning: OaiPmhError: OAI-PMH provider returned an error: The request includes illegal arguments, is missing required arguments, includes a repeated argument, or values for arguments have an illegal syntax.
at new OaiPmhError (/Users/matteo/node_modules/oai-pmh/src/errors.js:8:11)
at parseOaiPmhXml (/Users/matteo/node_modules/oai-pmh/src/oai-pmh-xml.js:24:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:23762) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:23762) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Perhaps we want
explicitArray: false,
normalize: true,
trim: true,
in xml2js.
How to reproduce.
oai-pmh list-sets https://oai.mikromarc.no/OAI/mic
The reason is that the result will not be an array because of the option to parseString explicitArray: false,. This results in that you can't iterate on it.
There is two ways to solve this in oai-pmh-list.js
Concat returned item into an array in both locations.
// Line 33
for (const item of [].concat(initialResult[field])) {
// Line 49
for (const item of [].concat(result[field])) {
A alternative is to check if the returned object if it is iterable.
if (typeof initialResult[field][Symbol.iterator] === 'function') {
for (const item of initialResult[field]) {
yield item
}
}
else {
yield initialResult[field]
}
if (typeof result[field][Symbol.iterator] === 'function') {
for (const item of result[field]) {
yield item
}
}
else {
yield result[field]
}
(node:17832) UnhandledPromiseRejectionWarning: Error: OAI-PMH provider returned an error: ListRecords verb must receive the metadataPrefix parameter
at new OaiPmhError (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:40:11)
at _parseOaiPmhXml (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:66:11)
at _parseOaiPmhXml.next (<anonymous>)
at onFulfilled (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/co/index.js:65:19)
at tryCatcher (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
(node:17832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:17832) UnhandledPromiseRejectionWarning: Error: OAI-PMH provider returned an error: ListRecords verb must receive the metadataPrefix parameter
at new OaiPmhError (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:40:11)
at _parseOaiPmhXml (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:66:11)
at _parseOaiPmhXml.next (<anonymous>)
at onFulfilled (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/co/index.js:65:19)
at tryCatcher (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
(node:17832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
When trying to harvest "http://arca.igc.gulbenkian.pt/oaiextended/request"
Do you know why is getting me this compiling error?
I'm just using the code in the example
I run using "node -r esm" like in the example and it run perfectly
**`import { OaiPmh } from 'oai-pmh'
async function main () {
const oaiPmh = new OaiPmh('http://export.arxiv.org/oai2')
const identifierIterator = oaiPmh.listIdentifiers({
metadataPrefix: 'oai_dc',
from: '2015-01-01',
until: '2015-01-04'
})
for await (const identifier of identifierIterator) {
console.log(identifier)
}
}
main().catch(console.error)`**
but when i tried to use in normal code compilng an app it gets me the following error:
Hi,
Could you update the library example to make easier for students to take the code and make it run straight away? Or, at least, provide a way of running it. Does it require babel to run?
Cheers.
When I tried to list records (or identifiers), I got
Error: OAI-PMH provider returned an error: The request is missing required arguments.
after the first batch. Testing a little bit confirmed that the error was caused by the resumption token being null
. When I had a look at the code to try to understand why, I was puzzled by line 39 in index.js:
resumptionToken: self.currentResult.resumptionToken._,
If I remove ._
it sends the resumption token correctly. But since the ._
has been there for so long, I assume it must have some intention? I'm only working with Node occasionally, so I'm not able to figure out what, though :)
To reproduce: With Node 8.6.0:
oai-pmh list-records -p marc21 -s oai_komplett http://bibsys-k.alma.exlibrisgroup.com/view/oai/47BIBSYS_UBO/request
Can you give me example?.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.