Explorer
/tmp/fbtest2.py
← Zurück ↓ Download
import asyncio, re
from playwright.async_api import async_playwright

async def try_url(p, url):
    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(url, wait_until="networkidle", timeout=60000)
        await pg.wait_for_timeout(8000)
        c = await pg.content()
        print("== ", url, " -> HTTP", r.status if r else "?", "| final:", pg.url[:90])
        print("   Titel:", (await pg.title())[:80])
        links = set(re.findall(r'/murprotec\.es/(?:posts|videos|photos)/[^"#?\\\s]*', c))
        print("   Post-Links:", len(links), list(links)[:3])
        print("   Seguidores-Treffer:", re.findall(r'[\d.,]+\s*(?:seguidores|Me gusta)', c)[:4])
        return
    except Exception as e:
        print("== ", url, "FEHLER:", str(e)[:150])
    finally:
        await b.close()

async def main():
    async with async_playwright() as p:
        await try_url(p, "https://m.facebook.com/murprotec.es/")
        await try_url(p, "https://www.facebook.com/murprotec.es/about")
asyncio.run(main())