Nexara is a lightweight Node.js module designed to fetch and parse web content efficiently. It also provides a utility for capturing webpage screenshots.
This module was created by Nimesh Piyumal.
- GitHub: Nimesh Piyumal
- Email: nimeshofficial.info@gmail.com
Feel free to contribute or report issues!
Install the module using npm:
npm install nexara
Fetching HTML Content
const nexara = require('nexara');
async function fetchHTML() {
try {
const response = await nexara.get("https://example.com");
console.log(response.data); // HTML content
} catch (error) {
console.error('Error:', error);
}
}
fetchHTML();
Parsing HTML
const nexara = require('nexara');
async function parseHTML() {
try {
const response = await nexara.get("https://example.com");
const $ = nexara.load(response.data);
// Example: Extract the page title
const title = $('title').text();
console.log('Page Title:', title);
} catch (error) {
console.error('Error:', error);
}
}
parseHTML();
Use the ssweb function to capture a screenshot of a webpage:
const nexara = require('nexara');
const fs = require('fs');
async function captureScreenshot() {
try {
const screenshot = await nexara.ssweb("https://example.com");
// Save the screenshot to a file
fs.writeFileSync('screenshot.png', screenshot);
console.log('Screenshot saved as screenshot.png');
} catch (error) {
console.error('Error:', error);
}
}
captureScreenshot();