You can use the Cheerio library and Axios HTTP request library for building accesible web scraping with Make.
Input:
{
"content": "<h2 class='title'>Hello World</h2>"
}
JavaScript Code:
// Load cheerio library for server-side HTML parsing
const cheerio = require('cheerio');
// Parse the HTML content from input
const $ = cheerio.load(input.content);
// Extract text from h2 element with class 'title'
return $("h2.title").text();
Output:
{
"output": "Hello World"
}
Input:
{
"url": "https://www.google.com/"
}
JavaScript Code:
const axios = require('axios');
const cheerio = require('cheerio');
const response = await axios.get(input.url);
const $ = cheerio.load(response.data);
return $("head title").text();
Output:
{
"output": "Google"
}