Women and Computers in library catalogues

node v8.17.0
version: 2.0.0
endpointsharetweet
A quick demo showing how RSS feeds from library OPACs return the same basic data regardless of the system.
const FeedParser = require('feedparser'); const request = require('request'); // for fetching the feed var results = ''; // var req = request('https://mylibrary.brimbank.vic.gov.au/cgi-bin/koha/opac-search.pl?idx=su&q=women%2520computer&count=50&sort_by=acqdate_dsc&format=rss2') // Brimbank (Koha ILS, RSS2) // var req = request('https://librarysearch.melbourne.vic.gov.au/cgi-bin/spydus.exe/ENQ/OPAC/BIBENQ?QRY=SU%3A%20(WOMEN%20%2B%20COMPUTER)&QRYTEXT=Subject%3A%20women%20computer%20(Keywords)&SETLVL=SET&CF=BIB&SORTS=DTE.DATE1.DESC&FMT=RSS&XSLT=rss.xsl&NRECS=30') // Melbourne (Civica Spydus, RSS) var req = request('https://coyl.swft.ent.sirsidynix.net.au/client/rss/hitlist/coylnow/qu=women+computer&lm=COYL-S&rt=false%7C%7C%7CSUBJECT%7C%7C%7CSubject') // Yarra (SirsiDynix Symphony, Atom) var feedparser = new FeedParser(); req.on('error', function (error) { console.error(error); }); req.on('response', function (res) { var stream = this; // `this` is `req`, which is a stream if (res.statusCode !== 200) { this.emit('error', new Error('Bad status code')); } else { stream.pipe(feedparser); } }); feedparser.on('error', function (error) { console.error(error); }); feedparser.on('readable', function () { var stream = this; var meta = this.meta; var item; while (item = stream.read()) { results += `<a href=${item.link}>${item.title}</a><br>` } }); function getResults() { return new Promise((resolve, reject) => { feedparser.on('end', function () { resolve(results) }) }); } module.exports.endpoint = async function(req, res) { let data = await getResults(); res.end(data); }
Loading…

no comments

    sign in to comment