Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastapi import FastAPI | |
| import os | |
| import asyncio | |
| from playwright.async_api import async_playwright | |
| # 🎯 SNIPER ENGINE | |
| async def quick_sniper_scan(url): | |
| try: | |
| # Docker imajımızda browserlar /ms-playwright altında | |
| async with async_playwright() as p: | |
| # Browser'ı daha garanti bir yöntemle başlatıyoruz | |
| browser = await p.chromium.launch( | |
| headless=True, | |
| args=["--no-sandbox", "--disable-setuid-sandbox"] | |
| ) | |
| context = await browser.new_context(viewport={'width': 1280, 'height': 720}) | |
| page = await context.new_page() | |
| print(f"Targeting: {url}") | |
| await page.goto(url, wait_until="networkidle", timeout=60000) | |
| title = await page.title() | |
| # Örnek Forensic: Sayfadaki linklerden ilk 15 tanesi | |
| links = await page.evaluate("() => Array.from(document.querySelectorAll('a')).map(a => (a.innerText || 'No Text').trim() + ' -> ' + a.href).slice(0, 15)") | |
| await browser.close() | |
| return { | |
| "status": "SUCCESS", | |
| "target": url, | |
| "title": title, | |
| "forensic_samples": links | |
| } | |
| except Exception as e: | |
| return {"status": "ERROR", "message": str(e)} | |
| # 🚀 API ENDPOINT | |
| app = FastAPI() | |
| async def remote_sniper(url: str): | |
| result = await quick_sniper_scan(url) | |
| return result | |
| # 🖥️ GRADIO UI | |
| with gr.Blocks(theme=gr.themes.Monochrome()) as demo: | |
| gr.Markdown("# 🧪 Scrape Raw: Remote Sniper Module (v2 - Docker)") | |
| with gr.Row(): | |
| url_input = gr.Textbox(label="Kazılacak Link", placeholder="https://...") | |
| run_btn = gr.Button("ATEŞ ET!", variant="primary") | |
| output = gr.JSON(label="Forensic Sonuçlar") | |
| run_btn.click(fn=lambda x: asyncio.run(quick_sniper_scan(x)), inputs=url_input, outputs=output) | |
| app = gr.mount_gradio_app(app, demo, path="/") | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) | |