im fetching data from different sources and the output string looks like the following:
"addressId":"132234","businessEntryCount":2026},{"district":"Nordend-West","districtSlug":"frankfurt-am-main-nordend-west","addressId":"132232","businessEntryCount":1925}],"generated":"2022-01-23 19:35:43.469","grisuLocation":null,"district":null,"geo":null};
kt.Data.SearchResult.distanceLocation = "Frankfurt am Main";
kt.Data.SearchResult.distanceStreetnumber = "";
kt.Service.citySlug = 'frankfurt';
kt.Data.what = 'Handwerker';
kt.Data.where = 'Frankfurt am Main';
kt.Data.trade = 'Maler';
{"@context":"http://schema.org","@type":"SearchResultsPage","mainEntity":{"@type":"ItemList","itemListElement":[{"@type":"ListItem","item":{"@type":"LocalBusiness","name":"Dachdecker Olaf Pocklitz","url":"http://www.test.de","email":"[email protected]","address":{"@type":"PostalAddress","postalCode":"65931","addressLocality":"Frankfurt","addressRegion":"Hessen",
The above string content is my data result. I want to have only all the email adresses left to save them in a file. In the above example it would be [email protected] and if we have more than one email adress, then I want the second email adress in a new line. Im struggling how to perfectly filter them out and afterwards save them one by line. I already made it work to save it but I dont know how to only get the email address out of it:
console.log('received data: ' + data)
fs.writeFileSync('./results/test.json', data)