Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from playwright.async_api import async_playwright
|
|
|
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
-
# Your 2026 Token
|
| 7 |
BEARER = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5M2NmYTBkMGU4YzlmMzdiZTA4Y2IyMCIsImlhdCI6MTczMjM5NTc5OSwiZXhwIjoxNzczMDAwNTk5fQ.Mc-LS_NMe0lpBQrQE4DEGs83iVBHIp8LvzBdeaUbmHo"
|
| 8 |
|
| 9 |
@app.get("/")
|
|
@@ -19,7 +19,6 @@ async def do_react(url: str, emojis: str):
|
|
| 19 |
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
| 20 |
)
|
| 21 |
|
| 22 |
-
# 🟢 PROPER COOKIE INJECTION (Forces the browser to be logged in)
|
| 23 |
await context.add_cookies([{
|
| 24 |
"name": "ain",
|
| 25 |
"value": BEARER,
|
|
@@ -28,37 +27,32 @@ async def do_react(url: str, emojis: str):
|
|
| 28 |
}])
|
| 29 |
|
| 30 |
page = await context.new_page()
|
| 31 |
-
|
| 32 |
-
# Go to the website
|
| 33 |
await page.goto("https://asitha.top/channel-react", wait_until="networkidle")
|
| 34 |
|
| 35 |
-
# Wait for the Pay button to appear (Proves we successfully bypassed login)
|
| 36 |
try:
|
|
|
|
| 37 |
await page.wait_for_selector("button:has-text('Pay 1 COIN')", timeout=10000)
|
| 38 |
-
except:
|
|
|
|
|
|
|
|
|
|
| 39 |
await browser.close()
|
| 40 |
-
return {"success": False, "error": "
|
| 41 |
|
| 42 |
-
# Grab all input boxes (Bypasses the 'type=url' bug)
|
| 43 |
inputs = await page.locator("input").all()
|
| 44 |
-
|
| 45 |
if len(inputs) >= 2:
|
| 46 |
await inputs[0].fill(url)
|
| 47 |
-
await page.wait_for_timeout(500)
|
| 48 |
await inputs[1].fill(emojis)
|
| 49 |
-
await page.wait_for_timeout(500)
|
| 50 |
-
|
| 51 |
-
# Click the yellow button!
|
| 52 |
await page.locator("button:has-text('Pay 1 COIN')").click()
|
| 53 |
-
|
| 54 |
-
# Wait 4 seconds for the server to process the reactions
|
| 55 |
await page.wait_for_timeout(4000)
|
| 56 |
-
|
| 57 |
await browser.close()
|
| 58 |
return {"success": True, "message": "Reaction injected successfully!"}
|
| 59 |
else:
|
|
|
|
|
|
|
|
|
|
| 60 |
await browser.close()
|
| 61 |
-
return {"success": False, "error":
|
| 62 |
|
| 63 |
except Exception as e:
|
| 64 |
return {"success": False, "error": str(e)}
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from playwright.async_api import async_playwright
|
| 3 |
+
import base64
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
|
|
|
| 7 |
BEARER = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY5M2NmYTBkMGU4YzlmMzdiZTA4Y2IyMCIsImlhdCI6MTczMjM5NTc5OSwiZXhwIjoxNzczMDAwNTk5fQ.Mc-LS_NMe0lpBQrQE4DEGs83iVBHIp8LvzBdeaUbmHo"
|
| 8 |
|
| 9 |
@app.get("/")
|
|
|
|
| 19 |
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
| 20 |
)
|
| 21 |
|
|
|
|
| 22 |
await context.add_cookies([{
|
| 23 |
"name": "ain",
|
| 24 |
"value": BEARER,
|
|
|
|
| 27 |
}])
|
| 28 |
|
| 29 |
page = await context.new_page()
|
|
|
|
|
|
|
| 30 |
await page.goto("https://asitha.top/channel-react", wait_until="networkidle")
|
| 31 |
|
|
|
|
| 32 |
try:
|
| 33 |
+
# Wait for the button. If it doesn't appear in 10 seconds, it will fail and jump to the 'except' block to take a screenshot.
|
| 34 |
await page.wait_for_selector("button:has-text('Pay 1 COIN')", timeout=10000)
|
| 35 |
+
except Exception as e:
|
| 36 |
+
# 📸 TAKE SCREENSHOT IF IT FAILS
|
| 37 |
+
screenshot_bytes = await page.screenshot(full_page=True)
|
| 38 |
+
screenshot_b64 = base64.b64encode(screenshot_bytes).decode('utf-8')
|
| 39 |
await browser.close()
|
| 40 |
+
return {"success": False, "error": "Stuck on login screen.", "image": screenshot_b64}
|
| 41 |
|
|
|
|
| 42 |
inputs = await page.locator("input").all()
|
|
|
|
| 43 |
if len(inputs) >= 2:
|
| 44 |
await inputs[0].fill(url)
|
|
|
|
| 45 |
await inputs[1].fill(emojis)
|
|
|
|
|
|
|
|
|
|
| 46 |
await page.locator("button:has-text('Pay 1 COIN')").click()
|
|
|
|
|
|
|
| 47 |
await page.wait_for_timeout(4000)
|
|
|
|
| 48 |
await browser.close()
|
| 49 |
return {"success": True, "message": "Reaction injected successfully!"}
|
| 50 |
else:
|
| 51 |
+
# 📸 TAKE SCREENSHOT IF BOXES ARE MISSING
|
| 52 |
+
screenshot_bytes = await page.screenshot(full_page=True)
|
| 53 |
+
screenshot_b64 = base64.b64encode(screenshot_bytes).decode('utf-8')
|
| 54 |
await browser.close()
|
| 55 |
+
return {"success": False, "error": "Could not find text boxes.", "image": screenshot_b64}
|
| 56 |
|
| 57 |
except Exception as e:
|
| 58 |
return {"success": False, "error": str(e)}
|