How to export a table from HTML response to CSV file and send a mail

Hello everyone in this community, first of all.

I want to run the collection using monitor daily morning and store the results in CSV and send it over mail

  1. Get the HTML reponse of the API
  2. Compare the date column in the response HTML table
  3. copy the entire row to csv if the completed date matches to the current date
<tr class="row1">
       <th class="field-id"><a href="/admin/">5360</a></th>
	<td class="field-staging_schema"></td>
	<td class="field-target_schema"></td>
	<td class="field-state">Completed</td>
	<td class="field-created_at nowrap">Aug. 2, 2022, 4 a.m.</td>
	<td class="field-completed_at nowrap">Aug. 2, 2022, 4:04 a.m.</td>

I tried this: const $ = cheerio.load(pm.response.text()); console.log($("tr:nth-child(2)").text());

but not sure

  1. How to compare current date in above format
  2. how to write the console output to CSV file without using Newman and send a mail

Please help