Code Examples

Scrapping an incoming email with cheerio

const cheerio = require('cheerio');

// this is an example data html - switch this to the email body -> _z.data.body
const data = `<div>
	<span class="firstName">Max</span>
  <span class="lastName">Muster</span>
</div>`;
 

var $ = cheerio.load(data);

const firstName = $('.firstName').text();
const lastName = $('.lastName').text();

console.log(firstName, lastName); 
// -> "Max", "Muster"

Last updated