const Parser = require('rss-parser'); const parser = new Parser(); const ORG = { CH : 1, BR: 1070, EDI: 301, BAG : 317, }; const base_url = 'https://www.newsd.admin.ch/newsd/feeds/rss'; //https://www.news.admin.ch/dienstleistungen/00008/00131/00146/index.html?lang=fr&rss-id=1_35 const get_url = function(opts){ const lang = opts.lang || 'de'; const org_nr = opts.org || '301'; const offer_nr = opts.offer || ''; const topic = opts.topic || ''; const sdate = opts.sdate || opts.since || '-1'; const edate = opts.edate || ''; const kind = opts.kind || 'M';//M,R,... return base_url+'?'+ '&lang='+lang+ '&org-nr='+org_nr+ '&topic='+topic+ //'&keyword='+ '&offer-nr='+offer_nr+ //'&catalogueElement='+ '&kind='+kind+ '&start_date='+sdate+ '&end_date='+edate; } const get_rss = function(url,min_id){ return parser.parseURL(url).then(feed=>feed.items .sort((a, b)=>(parseInt(a.guid)-parseInt(b.guid))) .filter((v)=>(parseInt(v.guid)>min_id))); } get_rss(get_url({org:ORG.BR, lang:'de',since:-2}),79710).then(r=>r.forEach(item=>{ console.log(item) //console.log(`${item.title} (${item.guid}): ${item.link}`); }));