const https = require('https');

// WMS for Renewable Energy NRW
const url = "https://www.wms.nrw.de/umwelt/erneuerbare_energien_wfs?REQUEST=GetCapabilities&SERVICE=WMS";
// Note: using WFS prefix in URL but requesting WMS caps? 
// The search result said: https://www.wms.nrw.de/umwelt/erneuerbare_energien_wfs for WFS
// and http://www.wms.nrw.de/umwelt/ea_wind?SERVICE=WMS for Wind.
// Let's try `ea_wind` and `erneuerbare_energien_nrw`.

const url1 = "https://www.wms.nrw.de/umwelt/ea_wind?SERVICE=WMS&REQUEST=GetCapabilities";

https.get(url1, (res) => {
    let data = '';
    res.on('data', chunk => data += chunk);
    res.on('end', () => {
        console.log("--- Caps for ea_wind ---");
        const names = [];
        const titles = [];
        let m;
        const nameRe = /<Name>(.*?)<\/Name>/g;
        while ((m = nameRe.exec(data)) !== null) names.push(m[1]);
        const titleRe = /<Title>(.*?)<\/Title>/g;
        while ((m = titleRe.exec(data)) !== null) titles.push(m[1]);

        console.log("Names:", names);
        console.log("Titles:", titles);
    });
}).on('error', e => console.log(e.message));
