import re
from playwright.sync_api import sync_playwright

OBJ_ID = 61060
IMG_PATTERN = re.compile(r"https://img\.artsmia\.org/[^\s\"'<>]+\.jpg")

def fetch_images_via_browser(obj_id):
    url = f"https://collections.artsmia.org/art/{obj_id}/"
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=True)
        page = browser.new_page()
        page.goto(url, wait_until="networkidle", timeout=30_000)
        rendered_html = page.content()
        browser.close()
    return list(dict.fromkeys(IMG_PATTERN.findall(rendered_html)))

images = fetch_images_via_browser(OBJ_ID)
print(f"Found {len(images)} image URL(s).")
for image_url in images:
    print(image_url)
if not images:
    print("No matching image URL was found; inspect the rendered page before changing the parser.")