
import asyncio, re
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        b = await p.chromium.launch(headless=True)
        ctx = await b.new_context(user_agent="Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1", viewport={"width":390,"height":844}, locale="es-ES")
        pg = await ctx.new_page()
        r = await pg.goto("https://www.facebook.com/murprotec.es/posts/", wait_until="domcontentloaded", timeout=60000)
        await pg.wait_for_timeout(8000)
        print("URL:", pg.url[:110])
        for i in range(5):
            try: await pg.mouse.wheel(0, 4000)
            except: pass
            await pg.wait_for_timeout(2000)
        c = await pg.content()
        links = set(re.findall(r'/murprotec\.es/(?:posts|videos|photos)/[^"#?\\\s]*', c))
        print("Post-Links:", len(links), list(links)[:4])
        txt = await pg.inner_text("body")
        print("TXT:", txt[:300].replace("\n"," | "))
        # Login-Form vorhanden?
        print("LOGIN_FORM:", bool(re.search(r'login_form|Iniciar sesi', c)))
        await b.close()
asyncio.run(main())
