File size: 2,723 Bytes
1fb4f8b
 
 
 
 
 
 
 
 
 
 
 
 
 
f516fd7
1fb4f8b
 
f516fd7
 
1fb4f8b
 
f516fd7
 
 
 
 
 
1fb4f8b
 
 
 
f516fd7
 
 
 
1fb4f8b
 
 
f516fd7
 
1fb4f8b
f516fd7
 
 
 
1fb4f8b
f516fd7
1fb4f8b
 
f516fd7
1fb4f8b
 
 
 
f516fd7
 
1fb4f8b
f516fd7
 
1fb4f8b
 
 
 
663c666
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Web Scraper</title>
    <link rel="stylesheet" href="/static/styles.css">
</head>
<body>
    <div class="container">
        <h1>Web Scraper</h1>
        <form id="scrapeForm">
            <div class="form-group">
                <label for="url">Website URL:</label>
                <input type="url" id="url" name="url" required placeholder="https://example.com">
            </div>
            <div class="form-group">
                <label for="email">Email Address:</label>
                <input type="email" id="email" name="email" required placeholder="your.email@example.com">
            </div>
            <div class="form-group">
                <label for="botName">Bot Name:</label>
                <input type="text" id="botName" name="botName" placeholder="Enter Bot Name">
            </div>
            <div class="form-group">
                <label for="apiToken">NativeMSG API Token:</label>
                <input type="password" id="apiToken" name="apiToken" placeholder="Enter NativeMSG Tokens">
            </div>
            <button type="submit">Scrape Website</button>
        </form>

        <div id="result">
            <h2>Result</h2>
            <div id="message"></div>
        </div>
    </div>

    <script>
        document.getElementById('scrapeForm').addEventListener('submit', async (e) => {
            e.preventDefault();
            const url = document.getElementById('url').value;
            const email = document.getElementById('email').value;
            const botName = document.getElementById('botName').value;
            const apiToken = document.getElementById('apiToken').value;
            const messageDiv = document.getElementById('message');

            messageDiv.textContent = 'Scraping in progress...';

            try {
                const response = await fetch(`/scrape?url=${encodeURIComponent(url)}&email=${encodeURIComponent(email)}${botName ? `&bot_name=${encodeURIComponent(botName)}` : ''}${apiToken ? `&nativemsg_token=${encodeURIComponent(apiToken)}` : ''}`);
                if (!response.ok) {
                    throw new Error(`HTTP error! Status: ${response.status}`);
                }
                const data = await response.json();
                messageDiv.textContent = `RCS for website is generated and sent to ${email}.`;
                messageDiv.style.color = 'green';
            } catch (error) {
                messageDiv.textContent = `Error: ${error.message}`;
                messageDiv.style.color = 'red';
            }
        });
    </script>
</body>
</html>