Add 3 files
Browse files- README.md +6 -4
- index.html +237 -19
- prompts.txt +2 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: blue
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: create-screenshot-from-page
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: purple
|
5 |
colorTo: blue
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,237 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>URL to Screenshot Converter</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.gradient-bg {
|
11 |
+
background: linear-gradient(135deg, #6e8efb, #a777e3);
|
12 |
+
}
|
13 |
+
.result-container {
|
14 |
+
transition: all 0.3s ease;
|
15 |
+
max-height: 0;
|
16 |
+
overflow: hidden;
|
17 |
+
}
|
18 |
+
.result-container.show {
|
19 |
+
max-height: 500px;
|
20 |
+
}
|
21 |
+
.glow {
|
22 |
+
box-shadow: 0 0 15px rgba(167, 119, 227, 0.7);
|
23 |
+
}
|
24 |
+
</style>
|
25 |
+
</head>
|
26 |
+
<body class="min-h-screen gradient-bg flex items-center justify-center p-4">
|
27 |
+
<div class="w-full max-w-2xl bg-white rounded-xl shadow-2xl overflow-hidden">
|
28 |
+
<div class="p-8">
|
29 |
+
<div class="flex items-center justify-center mb-6">
|
30 |
+
<i class="fas fa-camera-retro text-4xl text-purple-600 mr-3"></i>
|
31 |
+
<h1 class="text-3xl font-bold text-gray-800">URL Screenshot Capture</h1>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<p class="text-gray-600 mb-8 text-center">
|
35 |
+
Convert any webpage into a screenshot by simply entering its URL below.
|
36 |
+
Perfect for archiving, sharing, or documentation purposes.
|
37 |
+
</p>
|
38 |
+
|
39 |
+
<div class="mb-6">
|
40 |
+
<label for="url" class="block text-sm font-medium text-gray-700 mb-2">
|
41 |
+
<i class="fas fa-link mr-2 text-purple-500"></i> Enter Website URL
|
42 |
+
</label>
|
43 |
+
<div class="mt-1 relative rounded-md shadow-sm">
|
44 |
+
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
45 |
+
<span class="text-gray-500 sm:text-sm">https://</span>
|
46 |
+
</div>
|
47 |
+
<input type="text" id="url" name="url"
|
48 |
+
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"
|
49 |
+
placeholder="www.example.com">
|
50 |
+
<div class="absolute inset-y-0 right-0 flex items-center">
|
51 |
+
<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">
|
52 |
+
<i class="fas fa-camera mr-2"></i> Capture
|
53 |
+
</button>
|
54 |
+
</div>
|
55 |
+
</div>
|
56 |
+
</div>
|
57 |
+
|
58 |
+
<div class="flex items-center mb-6">
|
59 |
+
<input id="full-page" type="checkbox" class="h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded">
|
60 |
+
<label for="full-page" class="ml-2 block text-sm text-gray-700">
|
61 |
+
Capture full page (scroll and capture entire content)
|
62 |
+
</label>
|
63 |
+
</div>
|
64 |
+
|
65 |
+
<div id="result-container" class="result-container mt-6 bg-gray-50 rounded-lg p-4">
|
66 |
+
<div class="flex justify-between items-center mb-3">
|
67 |
+
<h3 class="text-lg font-medium text-gray-800">
|
68 |
+
<i class="fas fa-image mr-2 text-purple-500"></i> Screenshot Result
|
69 |
+
</h3>
|
70 |
+
<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">
|
71 |
+
<i class="fas fa-download mr-1"></i> Download
|
72 |
+
</button>
|
73 |
+
</div>
|
74 |
+
<div id="result" class="border border-gray-200 rounded p-2 bg-white">
|
75 |
+
<!-- Screenshot will appear here -->
|
76 |
+
<p class="text-gray-500 text-center py-10">Your screenshot will appear here after capture</p>
|
77 |
+
</div>
|
78 |
+
<div id="status" class="mt-2 text-sm text-gray-600"></div>
|
79 |
+
</div>
|
80 |
+
|
81 |
+
<div id="python-code" class="mt-10 bg-gray-800 rounded-lg overflow-hidden">
|
82 |
+
<div class="flex items-center justify-between bg-gray-700 px-4 py-2">
|
83 |
+
<span class="text-white text-sm font-mono">python_script.py</span>
|
84 |
+
<button id="copy-btn" class="text-gray-300 hover:text-white text-sm flex items-center">
|
85 |
+
<i class="far fa-copy mr-1"></i> Copy
|
86 |
+
</button>
|
87 |
+
</div>
|
88 |
+
<pre class="text-gray-200 p-4 overflow-x-auto text-sm font-mono" id="code-content">
|
89 |
+
import sys
|
90 |
+
import pyautogui
|
91 |
+
from selenium import webdriver
|
92 |
+
from selenium.webdriver.chrome.options import Options
|
93 |
+
from selenium.webdriver.chrome.service import Service
|
94 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
95 |
+
|
96 |
+
def take_screenshot(url, filename="screenshot.png", full_page=False):
|
97 |
+
try:
|
98 |
+
# Set up Chrome options
|
99 |
+
options = Options()
|
100 |
+
options.add_argument("--headless") # Run in headless mode
|
101 |
+
options.add_argument("--disable-gpu")
|
102 |
+
options.add_argument("--window-size=1920,1080")
|
103 |
+
|
104 |
+
# Initialize the driver
|
105 |
+
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
|
106 |
+
|
107 |
+
# Navigate to the URL
|
108 |
+
driver.get(url)
|
109 |
+
|
110 |
+
# Take screenshot
|
111 |
+
if full_page:
|
112 |
+
# Capture full page (requires scrolling)
|
113 |
+
total_height = driver.execute_script("return document.body.scrollHeight")
|
114 |
+
driver.set_window_size(1920, total_height)
|
115 |
+
driver.save_screenshot(filename)
|
116 |
+
else:
|
117 |
+
# Capture viewport only
|
118 |
+
pyautogui.screenshot(filename)
|
119 |
+
|
120 |
+
print(f"Screenshot saved as {filename}")
|
121 |
+
return True
|
122 |
+
except Exception as e:
|
123 |
+
print(f"Error: {str(e)}")
|
124 |
+
return False
|
125 |
+
finally:
|
126 |
+
driver.quit()
|
127 |
+
|
128 |
+
if __name__ == "__main__":
|
129 |
+
if len(sys.argv) < 2:
|
130 |
+
print("Usage: python screenshot.py <url> [output_filename] [--full-page]")
|
131 |
+
sys.exit(1)
|
132 |
+
|
133 |
+
url = sys.argv[1]
|
134 |
+
filename = sys.argv[2] if len(sys.argv) > 2 else "screenshot.png"
|
135 |
+
full_page = "--full-page" in sys.argv
|
136 |
+
|
137 |
+
success = take_screenshot(url, filename, full_page)
|
138 |
+
sys.exit(0 if success else 1)
|
139 |
+
</pre>
|
140 |
+
</div>
|
141 |
+
|
142 |
+
<div class="mt-8 text-center text-sm text-gray-500">
|
143 |
+
<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>
|
144 |
+
<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>
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
</div>
|
148 |
+
|
149 |
+
<script>
|
150 |
+
document.addEventListener('DOMContentLoaded', function() {
|
151 |
+
const captureBtn = document.getElementById('capture-btn');
|
152 |
+
const downloadBtn = document.getElementById('download-btn');
|
153 |
+
const copyBtn = document.getElementById('copy-btn');
|
154 |
+
const urlInput = document.getElementById('url');
|
155 |
+
const fullPageCheckbox = document.getElementById('full-page');
|
156 |
+
const resultContainer = document.getElementById('result-container');
|
157 |
+
const resultDiv = document.getElementById('result');
|
158 |
+
const statusDiv = document.getElementById('status');
|
159 |
+
const pythonCode = document.getElementById('code-content').textContent;
|
160 |
+
|
161 |
+
// Simulate screenshot capture (in a real app, this would call a backend API)
|
162 |
+
captureBtn.addEventListener('click', function() {
|
163 |
+
const url = urlInput.value.trim();
|
164 |
+
if (!url) {
|
165 |
+
alert('Please enter a valid URL');
|
166 |
+
return;
|
167 |
+
}
|
168 |
+
|
169 |
+
// Show loading state
|
170 |
+
captureBtn.disabled = true;
|
171 |
+
captureBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Capturing...';
|
172 |
+
statusDiv.textContent = 'Capturing screenshot...';
|
173 |
+
|
174 |
+
// Simulate API call delay
|
175 |
+
setTimeout(() => {
|
176 |
+
// Show result container
|
177 |
+
resultContainer.classList.add('show');
|
178 |
+
|
179 |
+
// In a real application, you would display the actual screenshot here
|
180 |
+
// For this demo, we'll show a placeholder
|
181 |
+
resultDiv.innerHTML = `
|
182 |
+
<div class="border-2 border-dashed border-gray-300 rounded p-4 text-center">
|
183 |
+
<i class="fas fa-image text-4xl text-gray-400 mb-2"></i>
|
184 |
+
<p class="text-gray-500">Screenshot of ${url}</p>
|
185 |
+
<p class="text-xs text-gray-400 mt-2">(In a real application, this would show the actual screenshot)</p>
|
186 |
+
</div>
|
187 |
+
`;
|
188 |
+
|
189 |
+
statusDiv.textContent = 'Screenshot captured successfully!';
|
190 |
+
statusDiv.className = 'mt-2 text-sm text-green-600';
|
191 |
+
|
192 |
+
// Reset button
|
193 |
+
captureBtn.disabled = false;
|
194 |
+
captureBtn.innerHTML = '<i class="fas fa-camera mr-2"></i> Capture';
|
195 |
+
|
196 |
+
// Enable download button
|
197 |
+
downloadBtn.disabled = false;
|
198 |
+
}, 2000);
|
199 |
+
});
|
200 |
+
|
201 |
+
// Simulate download
|
202 |
+
downloadBtn.addEventListener('click', function() {
|
203 |
+
statusDiv.textContent = 'Downloading screenshot...';
|
204 |
+
statusDiv.className = 'mt-2 text-sm text-blue-600';
|
205 |
+
|
206 |
+
setTimeout(() => {
|
207 |
+
statusDiv.textContent = 'Screenshot downloaded successfully!';
|
208 |
+
statusDiv.className = 'mt-2 text-sm text-green-600';
|
209 |
+
}, 1000);
|
210 |
+
});
|
211 |
+
|
212 |
+
// Copy Python code to clipboard
|
213 |
+
copyBtn.addEventListener('click', function() {
|
214 |
+
navigator.clipboard.writeText(pythonCode).then(() => {
|
215 |
+
const originalText = copyBtn.innerHTML;
|
216 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
217 |
+
copyBtn.classList.add('text-green-400');
|
218 |
+
|
219 |
+
setTimeout(() => {
|
220 |
+
copyBtn.innerHTML = originalText;
|
221 |
+
copyBtn.classList.remove('text-green-400');
|
222 |
+
}, 2000);
|
223 |
+
});
|
224 |
+
});
|
225 |
+
|
226 |
+
// Add glow effect on focus
|
227 |
+
urlInput.addEventListener('focus', function() {
|
228 |
+
this.parentElement.classList.add('glow');
|
229 |
+
});
|
230 |
+
|
231 |
+
urlInput.addEventListener('blur', function() {
|
232 |
+
this.parentElement.classList.remove('glow');
|
233 |
+
});
|
234 |
+
});
|
235 |
+
</script>
|
236 |
+
<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>
|
237 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
create me a python script that takes a link as input and saves it as a screenshot
|
2 |
+
make me a script in python that plays a internetstream like one from di.fm
|