import asyncio, json
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126 Safari/537.36",
locale="es-ES")
pg = await ctx.new_page()
try:
r = await pg.goto("https://www.facebook.com/murprotec.es", wait_until="domcontentloaded", timeout=45000)
print("HTTP:", r.status if r else "?")
await pg.wait_for_timeout(6000)
title = await pg.title()
print("TITEL:", title[:120])
url = pg.url
print("URL_NACH_LOAD:", url)
content = await pg.content()
print("LOGIN_WALL:", "login" in url.lower() or "Iniciar" in content[:20000])
# Follower/Likes suchen
import re
m = re.findall(r'([\d.,]+)\s*(?:Me gusta|likes|seguidores|followers)', content)
print("FOLLOWER_TREFFER:", m[:6])
# Post-Links
links = set(re.findall(r'https://www\.facebook\.com/murprotec\.es/(?:posts|videos|photos)/[^"#?\\]*', content))
print("POST_LINKS:", len(links));
for l in list(links)[:5]: print(" ", l)
# Kommentar-Hinweise
print("KOMMENTAR_HINWEISE:", content.count("comentario"))
await pg.screenshot(path="/tmp/fb_test.png", full_page=False)
print("SCREENSHOT_OK")
except Exception as e:
print("FEHLER:", type(e).__name__, str(e)[:300])
finally:
await b.close()
asyncio.run(main())