fix: review findings - OUTPUT_DIR centralised, no hardcoded vwts.ru, normal imports

This commit is contained in:
2026-06-04 09:08:51 +03:00
parent 1cfa6d1595
commit 4a3d5d21d1
14 changed files with 12 additions and 13 deletions
+7 -4
View File
@@ -1,7 +1,9 @@
"""Основной цикл: обход страниц раздела → темы → посты → сохранение."""
import sys, logging
from .config import HEADERS
from pathlib import Path
from urllib.parse import urlparse
from .config import OUTPUT_DIR
from .fetch import get, session
from .paginate import count, verify_last
from .parse import parse_topics, parse_posts, parse_tags
@@ -85,11 +87,13 @@ def run(section_url: str):
posts, tags = [], parse_tags(topic_soup)
# ── Обход страниц темы ────────────────────────────────────
base = f"{urlparse(section_url).scheme}://{urlparse(section_url).netloc}"
for tpp in range(1, topic_pages + 1):
if tpp == 1:
posts += parse_posts(topic_soup)
else:
tp2 = get(f"https://vwts.ru/forum/topic/{tid}/page-{tpp}")
tp2 = get(f"{base}/forum/topic/{tid}/page-{tpp}")
if tp2:
posts += parse_posts(tp2)
@@ -106,7 +110,6 @@ def run(section_url: str):
log.info("=" * 60)
log.info(f"'{section_name}'{st['topic_count']} тем "
f"в {st['file_index']+1} частях")
for f in sorted((__import__('pathlib').Path('vwts_data') /
section_slug).glob("part_*.jsonl")):
for f in sorted((OUTPUT_DIR / section_slug).glob("part_*.jsonl")):
log.info(f" 📄 {f.name} ({f.stat().st_size/1024/1024:.1f} MB)")
log.info("=" * 60)