Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -5,7 +5,8 @@ from typing import Optional
|
|
| 5 |
from playwright.async_api import async_playwright
|
| 6 |
from playwright_stealth import stealth_async
|
| 7 |
|
| 8 |
-
app = FastAPI(title="
|
|
|
|
| 9 |
MASTER_API_KEY = os.getenv("API_KEY", "rh5152..")
|
| 10 |
|
| 11 |
class CommandPayload(BaseModel):
|
|
@@ -16,7 +17,7 @@ class CommandPayload(BaseModel):
|
|
| 16 |
|
| 17 |
@app.get("/")
|
| 18 |
async def health_check():
|
| 19 |
-
return {"status": "System Online", "message": "
|
| 20 |
|
| 21 |
@app.post("/api/v1/execute")
|
| 22 |
async def execute_browser_task(payload: CommandPayload, x_api_key: str = Header(None)):
|
|
@@ -26,24 +27,21 @@ async def execute_browser_task(payload: CommandPayload, x_api_key: str = Header(
|
|
| 26 |
async with async_playwright() as p:
|
| 27 |
browser = await p.chromium.launch(
|
| 28 |
headless=True,
|
| 29 |
-
args=[
|
| 30 |
-
"--no-sandbox",
|
| 31 |
-
"--disable-setuid-sandbox",
|
| 32 |
-
"--disable-dev-shm-usage",
|
| 33 |
-
"--disable-blink-features=AutomationControlled",
|
| 34 |
-
"--window-size=1920,1080",
|
| 35 |
-
"--disable-web-security"
|
| 36 |
-
]
|
| 37 |
)
|
| 38 |
|
| 39 |
context = await browser.new_context(
|
| 40 |
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
|
| 41 |
-
viewport={"width": 1920, "height": 1080}
|
| 42 |
-
java_script_enabled=True
|
| 43 |
)
|
| 44 |
|
| 45 |
-
# 🔥
|
| 46 |
-
await context.add_init_script("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
page = await context.new_page()
|
| 49 |
await stealth_async(page)
|
|
@@ -58,8 +56,8 @@ async def execute_browser_task(payload: CommandPayload, x_api_key: str = Header(
|
|
| 58 |
|
| 59 |
return {
|
| 60 |
"status": "success",
|
| 61 |
-
"current_url": page.url,
|
| 62 |
"js_output": script_result,
|
|
|
|
| 63 |
"html_extracted": bool(html_content)
|
| 64 |
}
|
| 65 |
except Exception as e:
|
|
|
|
| 5 |
from playwright.async_api import async_playwright
|
| 6 |
from playwright_stealth import stealth_async
|
| 7 |
|
| 8 |
+
app = FastAPI(title="Omni-Digital Cloud Engine", version="3.0")
|
| 9 |
+
# আপনার কাস্টম কি সেট করা হলো
|
| 10 |
MASTER_API_KEY = os.getenv("API_KEY", "rh5152..")
|
| 11 |
|
| 12 |
class CommandPayload(BaseModel):
|
|
|
|
| 17 |
|
| 18 |
@app.get("/")
|
| 19 |
async def health_check():
|
| 20 |
+
return {"status": "System Online", "message": "Stealth Mode v3.0 Active."}
|
| 21 |
|
| 22 |
@app.post("/api/v1/execute")
|
| 23 |
async def execute_browser_task(payload: CommandPayload, x_api_key: str = Header(None)):
|
|
|
|
| 27 |
async with async_playwright() as p:
|
| 28 |
browser = await p.chromium.launch(
|
| 29 |
headless=True,
|
| 30 |
+
args=["--no-sandbox", "--disable-setuid-sandbox", "--disable-blink-features=AutomationControlled"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
)
|
| 32 |
|
| 33 |
context = await browser.new_context(
|
| 34 |
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
|
| 35 |
+
viewport={"width": 1920, "height": 1080}
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
+
# 🔥 অ্যাডভান্সড স্টিলথ ইনজেকশন (এটি অডিট পাস করাবে) 🔥
|
| 39 |
+
await context.add_init_script("""
|
| 40 |
+
Object.defineProperty(navigator, 'webdriver', {get: () => false});
|
| 41 |
+
window.chrome = { runtime: {} };
|
| 42 |
+
Object.defineProperty(navigator, 'languages', {get: () => ['en-US', 'en']});
|
| 43 |
+
Object.defineProperty(navigator, 'plugins', {get: () => [1, 2, 3, 4, 5]});
|
| 44 |
+
""")
|
| 45 |
|
| 46 |
page = await context.new_page()
|
| 47 |
await stealth_async(page)
|
|
|
|
| 56 |
|
| 57 |
return {
|
| 58 |
"status": "success",
|
|
|
|
| 59 |
"js_output": script_result,
|
| 60 |
+
"current_url": page.url,
|
| 61 |
"html_extracted": bool(html_content)
|
| 62 |
}
|
| 63 |
except Exception as e:
|