Парсер: поддержка латиницы (международные турниры) + таблица: колонки Рейт и Доп1
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 8s

This commit is contained in:
vrubel 2026-06-19 14:51:15 +00:00
parent 7f627beeec
commit 22a0e27763
2 changed files with 43 additions and 14 deletions

View file

@ -82,6 +82,19 @@ def _has_cyrillic(s: str) -> bool:
return bool(re.search(r'[а-яА-ЯёЁ]', s))
def _is_player_name(t: str) -> bool:
"""Check if text looks like a player name (Latin or Cyrillic)."""
if len(t) <= 5:
return False
if re.match(r'^\d+$', t):
return False
if re.match(r'^[A-Z]{3}$', t):
return False
if re.match(r'^\d+[bw][½\d]?$', t):
return False
return bool(re.search(r'[A-Za-zА-Яа-я]', t))
def parse_standings(html: str) -> List[Dict]:
"""Parse standings from art=4 or art=5 page.
@ -110,11 +123,11 @@ def parse_standings(html: str) -> List[Dict]:
if sno < 1 or sno > 300:
continue
# Find name: look for Cyrillic text
# Find name: look for player name (Latin or Cyrillic)
name = ''
name_idx = -1
for ci, t in enumerate(texts):
if _has_cyrillic(t) and len(t) > 5:
if _is_player_name(t):
name = t
name_idx = ci
break
@ -517,7 +530,7 @@ def parse_start_list(html: str) -> dict:
for row in rows:
cells = row.find_all('td')
texts = [c.get_text(strip=True) for c in cells]
if len(texts) >= 4 and texts[0].isdigit() and _has_cyrillic(' '.join(texts)):
if len(texts) >= 4 and texts[0].isdigit() and any(_is_player_name(t) for t in texts):
data_rows += 1
if data_rows < 5:
continue
@ -531,7 +544,7 @@ def parse_start_list(html: str) -> dict:
fed = ''
rating = 0
for ci, t in enumerate(texts[1:], 1):
if _has_cyrillic(t) and len(t) > 5 and not name:
if _is_player_name(t) and not name:
name = t
if ci + 1 < len(texts) and re.match(r'^[A-Z]{3}$', texts[ci + 1]):
fed = texts[ci + 1]