import sys, time
from pathlib import Path
sys.path.insert(0, '/app')
from pinterest.client import PinterestClient

data_dir = Path('/app/data/pinterest')
with PinterestClient(data_dir) as client:
    client.is_authenticated()
    client.page.goto('https://www.pinterest.com/rmacsparran/_created/', timeout=30000)
    time.sleep(5)

    # Find all board links
    boards = []
    for e in client.page.query_selector_all('a[href*="/rmacsparran/"]'):
        href = e.get_attribute('href') or ''
        txt = (e.inner_text() or '').strip()[:60]
        if href and href not in ('/rmacsparran/', '/rmacsparran/_created/', '/rmacsparran/_saved/'):
            boards.append({'href': href, 'txt': txt})
    print(f'Boards found: {len(boards)}')
    for b in boards:
        print(f'  {b}')
