notebookvb

This commit is contained in:
Vladimir Buzalka
2026-05-08 13:30:47 +02:00
parent ee6fd79f5c
commit c9903646f1
20 changed files with 2024 additions and 56 deletions
@@ -0,0 +1,89 @@
"""
Průzkumný skript: připojí se na solitaire.org/daily-suguru/ a vytáhne
surová JS data o puzzle (gameLevels, Game objekt).
"""
import asyncio
import json
import sys
sys.stdout.reconfigure(encoding="utf-8")
from playwright.async_api import async_playwright
URL = "https://www.solitaire.org/daily-suguru/"
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
context = await browser.new_context(viewport={"width": 1280, "height": 900})
page = await context.new_page()
print(f"Načítám {URL} ...")
await page.goto(URL, wait_until="networkidle", timeout=60_000)
game_url = None
for frame in page.frames:
if frame.url != page.url and frame.url.strip() not in ("", "about:blank"):
game_url = frame.url
print(f" Nalezen iframe: {game_url}")
break
if not game_url:
iframe_src = await page.get_attribute("iframe", "src")
if iframe_src:
game_url = iframe_src if iframe_src.startswith("http") else f"https://www.solitaire.org{iframe_src}"
print(f" Iframe src z DOM: {game_url}")
await page.close()
game_page = await context.new_page()
target_url = game_url if game_url else URL
print(f"Načítám hru: {target_url} ...")
await game_page.goto(target_url, wait_until="networkidle", timeout=60_000)
# 1) gameLevels — struktura
print("\n=== gameLevels — struktura ===")
structure = await game_page.evaluate("""() => {
if (typeof gameLevels === 'undefined') return null;
const result = {};
for (const diff of Object.keys(gameLevels)) {
const keys = Object.keys(gameLevels[diff]);
result[diff] = {
count: keys.length,
first_keys: keys.slice(0, 3),
last_keys: keys.slice(-3),
sample_value: gameLevels[diff][keys[0]]
};
}
return result;
}""")
if structure:
print(json.dumps(structure, indent=2, ensure_ascii=False)[:8000])
else:
print(" gameLevels není definováno")
# 2) Dnešní data
print("\n=== Dnešní data (05-08) ===")
today_data = await game_page.evaluate("""() => {
const key = '05-08';
const result = {};
if (typeof gameLevels === 'undefined') return null;
for (const diff of Object.keys(gameLevels)) {
if (gameLevels[diff] && gameLevels[diff][key]) {
result[diff] = gameLevels[diff][key];
}
}
return result;
}""")
if today_data:
print(json.dumps(today_data, indent=2, ensure_ascii=False)[:8000])
else:
print(" žádná data pro dnešek")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())