Merge pull request #219 from R0m1k3/antigravity

feat: Add Playwright script to detect and analyze Amazon "Continuer l…
This commit is contained in:
LogiFlow authored and GitHub committed 2025-12-01 17:27:13 +01:00
commit 468ad432b9
2 files changed
+65

No files matched your search

+3
View File
@@ -53,6 +53,9 @@ POPUP_SELECTORS = [
"button:has-text('Continuer les achats')",
"span:has-text('Continuer les achats')",
"a:has-text('Continuer les achats')",
"input[value='Continuer les achats']",
"input[value='Continue shopping']",
"form:has-text('Continuer les achats') input[type='submit']",
]
+62
View File
@@ -0,0 +1,62 @@
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
# Launch with headless=True to mimic server environment
browser = await p.chromium.launch(headless=True)
context = await browser.new_context(
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
)
page = await context.new_page()
# Try a product URL that might trigger the check
url = "https://www.amazon.fr/dp/B07S58MPKW"
print(f"Navigating to {url}")
try:
await page.goto(url)
await page.wait_for_timeout(5000)
content = await page.content()
if "Continuer les achats" in content:
print("🚨 Popup detected!")
with open("amazon_popup.html", "w", encoding="utf-8") as f:
f.write(content)
await page.screenshot(path="amazon_popup.png")
# Analyze the button
print("Searching for button...")
# Try various locators
locators = [
"button",
"input[type='submit']",
"a.a-button-text",
"span.a-button-inner"
]
for sel in locators:
elements = page.locator(sel)
count = await elements.count()
for i in range(count):
el = elements.nth(i)
if await el.is_visible():
txt = await el.inner_text()
val = await el.get_attribute("value") or ""
if "Continuer" in txt or "Continuer" in val:
print(f"✅ Found candidate: {sel}")
print(f" Text: {txt}")
print(f" Value: {val}")
print(f" OuterHTML: {await el.evaluate('el => el.outerHTML')}")
else:
print("No popup detected. Page title:", await page.title())
except Exception as e:
print(f"Error: {e}")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())