File size: 12,036 Bytes
fda306b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>URL to Screenshot Converter</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
        }
        .result-container {
            transition: all 0.3s ease;
            max-height: 0;
            overflow: hidden;
        }
        .result-container.show {
            max-height: 500px;
        }
        .glow {
            box-shadow: 0 0 15px rgba(167, 119, 227, 0.7);
        }
    </style>
</head>
<body class="min-h-screen gradient-bg flex items-center justify-center p-4">
    <div class="w-full max-w-2xl bg-white rounded-xl shadow-2xl overflow-hidden">
        <div class="p-8">
            <div class="flex items-center justify-center mb-6">
                <i class="fas fa-camera-retro text-4xl text-purple-600 mr-3"></i>
                <h1 class="text-3xl font-bold text-gray-800">URL Screenshot Capture</h1>
            </div>
            
            <p class="text-gray-600 mb-8 text-center">
                Convert any webpage into a screenshot by simply entering its URL below.
                Perfect for archiving, sharing, or documentation purposes.
            </p>
            
            <div class="mb-6">
                <label for="url" class="block text-sm font-medium text-gray-700 mb-2">
                    <i class="fas fa-link mr-2 text-purple-500"></i> Enter Website URL
                </label>
                <div class="mt-1 relative rounded-md shadow-sm">
                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                        <span class="text-gray-500 sm:text-sm">https://</span>
                    </div>
                    <input type="text" id="url" name="url" 
                           class="focus:ring-purple-500 focus:border-purple-500 block w-full pl-16 pr-12 py-3 sm:text-sm border-gray-300 rounded-md border" 
                           placeholder="www.example.com">
                    <div class="absolute inset-y-0 right-0 flex items-center">
                        <button id="capture-btn" class="px-4 py-2 bg-purple-600 text-white rounded-r-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 flex items-center">
                            <i class="fas fa-camera mr-2"></i> Capture
                        </button>
                    </div>
                </div>
            </div>
            
            <div class="flex items-center mb-6">
                <input id="full-page" type="checkbox" class="h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded">
                <label for="full-page" class="ml-2 block text-sm text-gray-700">
                    Capture full page (scroll and capture entire content)
                </label>
            </div>
            
            <div id="result-container" class="result-container mt-6 bg-gray-50 rounded-lg p-4">
                <div class="flex justify-between items-center mb-3">
                    <h3 class="text-lg font-medium text-gray-800">
                        <i class="fas fa-image mr-2 text-purple-500"></i> Screenshot Result
                    </h3>
                    <button id="download-btn" class="px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 flex items-center">
                        <i class="fas fa-download mr-1"></i> Download
                    </button>
                </div>
                <div id="result" class="border border-gray-200 rounded p-2 bg-white">
                    <!-- Screenshot will appear here -->
                    <p class="text-gray-500 text-center py-10">Your screenshot will appear here after capture</p>
                </div>
                <div id="status" class="mt-2 text-sm text-gray-600"></div>
            </div>
            
            <div id="python-code" class="mt-10 bg-gray-800 rounded-lg overflow-hidden">
                <div class="flex items-center justify-between bg-gray-700 px-4 py-2">
                    <span class="text-white text-sm font-mono">python_script.py</span>
                    <button id="copy-btn" class="text-gray-300 hover:text-white text-sm flex items-center">
                        <i class="far fa-copy mr-1"></i> Copy
                    </button>
                </div>
                <pre class="text-gray-200 p-4 overflow-x-auto text-sm font-mono" id="code-content">
import sys
import pyautogui
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

def take_screenshot(url, filename="screenshot.png", full_page=False):
    try:
        # Set up Chrome options
        options = Options()
        options.add_argument("--headless")  # Run in headless mode
        options.add_argument("--disable-gpu")
        options.add_argument("--window-size=1920,1080")
        
        # Initialize the driver
        driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
        
        # Navigate to the URL
        driver.get(url)
        
        # Take screenshot
        if full_page:
            # Capture full page (requires scrolling)
            total_height = driver.execute_script("return document.body.scrollHeight")
            driver.set_window_size(1920, total_height)
            driver.save_screenshot(filename)
        else:
            # Capture viewport only
            pyautogui.screenshot(filename)
        
        print(f"Screenshot saved as {filename}")
        return True
    except Exception as e:
        print(f"Error: {str(e)}")
        return False
    finally:
        driver.quit()

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python screenshot.py <url> [output_filename] [--full-page]")
        sys.exit(1)
    
    url = sys.argv[1]
    filename = sys.argv[2] if len(sys.argv) > 2 else "screenshot.png"
    full_page = "--full-page" in sys.argv
    
    success = take_screenshot(url, filename, full_page)
    sys.exit(0 if success else 1)
                </pre>
            </div>
            
            <div class="mt-8 text-center text-sm text-gray-500">
                <p>This Python script requires <span class="font-mono bg-gray-100 px-2 py-1 rounded">selenium</span>, <span class="font-mono bg-gray-100 px-2 py-1 rounded">pyautogui</span>, and <span class="font-mono bg-gray-100 px-2 py-1 rounded">webdriver-manager</span>.</p>
                <p class="mt-2">Install them with: <span class="font-mono bg-gray-100 px-2 py-1 rounded">pip install selenium pyautogui webdriver-manager</span></p>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const captureBtn = document.getElementById('capture-btn');
            const downloadBtn = document.getElementById('download-btn');
            const copyBtn = document.getElementById('copy-btn');
            const urlInput = document.getElementById('url');
            const fullPageCheckbox = document.getElementById('full-page');
            const resultContainer = document.getElementById('result-container');
            const resultDiv = document.getElementById('result');
            const statusDiv = document.getElementById('status');
            const pythonCode = document.getElementById('code-content').textContent;
            
            // Simulate screenshot capture (in a real app, this would call a backend API)
            captureBtn.addEventListener('click', function() {
                const url = urlInput.value.trim();
                if (!url) {
                    alert('Please enter a valid URL');
                    return;
                }
                
                // Show loading state
                captureBtn.disabled = true;
                captureBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Capturing...';
                statusDiv.textContent = 'Capturing screenshot...';
                
                // Simulate API call delay
                setTimeout(() => {
                    // Show result container
                    resultContainer.classList.add('show');
                    
                    // In a real application, you would display the actual screenshot here
                    // For this demo, we'll show a placeholder
                    resultDiv.innerHTML = `
                        <div class="border-2 border-dashed border-gray-300 rounded p-4 text-center">
                            <i class="fas fa-image text-4xl text-gray-400 mb-2"></i>
                            <p class="text-gray-500">Screenshot of ${url}</p>
                            <p class="text-xs text-gray-400 mt-2">(In a real application, this would show the actual screenshot)</p>
                        </div>
                    `;
                    
                    statusDiv.textContent = 'Screenshot captured successfully!';
                    statusDiv.className = 'mt-2 text-sm text-green-600';
                    
                    // Reset button
                    captureBtn.disabled = false;
                    captureBtn.innerHTML = '<i class="fas fa-camera mr-2"></i> Capture';
                    
                    // Enable download button
                    downloadBtn.disabled = false;
                }, 2000);
            });
            
            // Simulate download
            downloadBtn.addEventListener('click', function() {
                statusDiv.textContent = 'Downloading screenshot...';
                statusDiv.className = 'mt-2 text-sm text-blue-600';
                
                setTimeout(() => {
                    statusDiv.textContent = 'Screenshot downloaded successfully!';
                    statusDiv.className = 'mt-2 text-sm text-green-600';
                }, 1000);
            });
            
            // Copy Python code to clipboard
            copyBtn.addEventListener('click', function() {
                navigator.clipboard.writeText(pythonCode).then(() => {
                    const originalText = copyBtn.innerHTML;
                    copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
                    copyBtn.classList.add('text-green-400');
                    
                    setTimeout(() => {
                        copyBtn.innerHTML = originalText;
                        copyBtn.classList.remove('text-green-400');
                    }, 2000);
                });
            });
            
            // Add glow effect on focus
            urlInput.addEventListener('focus', function() {
                this.parentElement.classList.add('glow');
            });
            
            urlInput.addEventListener('blur', function() {
                this.parentElement.classList.remove('glow');
            });
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=thc256v2/create-screenshot-from-page" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>