# -*- coding: utf-8 -*- import requests import json import re import time from bs4 import BeautifulSoup BASE_URL = "https://jimm.name/status/?status=1&sort=1" headers = { "User-Agent": "Mozilla/5.0" } all_statuses = [] page = 1 while True: url = BASE_URL + "&p=%d" % page print("Страница", page) try: r = requests.get(url, headers=headers, timeout=15) except Exception as e: print("Ошибка:", e) break if r.status_code != 200: break html = r.text soup = BeautifulSoup(html, "html.parser") cells = soup.find_all("td", class_="s") if not cells: break added = 0 for cell in cells: span = cell.find("span", class_="m") if not span: continue style = span.get("style", "") m = re.search( r'background-position:\s*(-?\d+)px\s*(-?\d+)px', style ) icon = None if m: icon = "%s_%s" % (m.group(1), m.group(2)) text = cell.get_text("\n", strip=True) if text: all_statuses.append({ "icon": icon, "text": text }) added += 1 print("Найдено:", added) with open("statuses.json", "w", encoding="utf-8") as f: json.dump(all_statuses, f, ensure_ascii=False, indent=2) print("Всего сохранено:", len(all_statuses)) if page > 1 and added == 0: break page += 1 time.sleep(0.3) with open("statuses.json", "w", encoding="utf-8") as f: json.dump(all_statuses, f, ensure_ascii=False, indent=2) print("Сохранено:", len(all_statuses))