GUI Website Scanner

Creating a website scanner using Electron.js involves making HTTP requests to the target websites and analyzing the responses. Below is a simple example of an Electron.js-based website scanner that checks the status (HTTP response code) of a list of websites and displays the results. First, make sure you have Node.js and npm installed on your system.

we are happy to serve you

Let's start a project.

  1. Create a new Electron project and navigate into the project directory:
mkdir electron-website-scanner
cd electron-website-scanner
npm init -y
  1. Install Electron and Axios (a popular HTTP client for Node.js):
npm install electron axios --save
  1. Create the following files:

index.html:

htmlCopy code<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Website Scanner</title>
</head>
<body>
    <h1>Website Scanner</h1>
    <textarea id="websites" placeholder="Enter websites (one per line)"></textarea>
    <button id="scanButton">Scan</button>
    <div id="results"></div>
    <script src="renderer.js"></script>
</body>
</html>

main.js:

const { app, BrowserWindow } = require('electron');
const path = require('path');

let mainWindow;

function createWindow() {
    mainWindow = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            nodeIntegration: true
        }
    });

    mainWindow.loadFile('index.html');
}

app.on('ready', createWindow);

// Quit when all windows are closed
app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') app.quit();
});

app.on('activate', function () {
    if (mainWindow === null) createWindow();
});

renderer.js:

const axios = require('axios');

document.getElementById('scanButton').addEventListener('click', async () => {
    const websitesInput = document.getElementById('websites').value;
    const websites = websitesInput.split('\n').map(url => url.trim());

    const resultsDiv = document.getElementById('results');
    resultsDiv.innerHTML = '';

    for (const website of websites) {
        try {
            const response = await axios.get(website);
            const status = response.status;
            resultsDiv.innerHTML += `<p>${website} - Status: ${status}</p>`;
        } catch (error) {
            resultsDiv.innerHTML += `<p>${website} - Error: ${error.message}</p>`;
        }
    }
});

we are happy to serve you

Let's start a project.

In this example, index.html provides an input field for entering websites and a button to trigger the scanning process. When the button is clicked, the renderer.js script makes HTTP requests to each website using the Axios library. The results are displayed in the results div.

To run the Electron application, add the following script in your package.json file:

jsonCopy code"scripts": {
    "start": "electron main.js"
}

Now, you can start your Electron website scanner by running:

npm start

This will launch the Electron application, allowing you to enter websites, click the "Scan" button, and view the HTTP response statuses. Please note that this example provides basic functionality and can be further enhanced for more complex scanning tasks.

we are happy to serve you

Let's start a project.


Electron.js Developer
hire xamta infotech for your GUI Application Development