|
<!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"> |
|
|
|
<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; |
|
|
|
|
|
captureBtn.addEventListener('click', function() { |
|
const url = urlInput.value.trim(); |
|
if (!url) { |
|
alert('Please enter a valid URL'); |
|
return; |
|
} |
|
|
|
|
|
captureBtn.disabled = true; |
|
captureBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Capturing...'; |
|
statusDiv.textContent = 'Capturing screenshot...'; |
|
|
|
|
|
setTimeout(() => { |
|
|
|
resultContainer.classList.add('show'); |
|
|
|
|
|
|
|
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'; |
|
|
|
|
|
captureBtn.disabled = false; |
|
captureBtn.innerHTML = '<i class="fas fa-camera mr-2"></i> Capture'; |
|
|
|
|
|
downloadBtn.disabled = false; |
|
}, 2000); |
|
}); |
|
|
|
|
|
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); |
|
}); |
|
|
|
|
|
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); |
|
}); |
|
}); |
|
|
|
|
|
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> |