#!/usr/bin/env python3
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    b = p.chromium.launch()
    ctx = b.new_context(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")
    page = ctx.new_page()
    page.goto("https://franciscoborrello.com.br/blog/", wait_until="networkidle", timeout=45000)
    # Pega os primeiros links de posts
    links = page.eval_on_selector_all("a", "els => els.map(e => e.href).filter(h => h.includes('franciscoborrello.com.br') && !h.includes('#') && !h.includes('/blog/') && !h.includes('/wp-') && !h.includes('/tag/') && !h.includes('/category/') && !h.includes('/cursos') && !h.includes('/sobre') && !h.includes('/videos') && !h.includes('/loja') && !h.includes('/fale') && !h.includes('/home') && !h.includes('/escalada') && !h.includes('/chacara') && !h.includes('/depoimentos') && !h.endsWith('.br/') && !h.endsWith('.br'))")
    for l in list(set(links))[:15]:
        print(l)
    b.close()
