Skip to content

Instantly share code, notes, and snippets.

@met
Created January 27, 2026 12:56
Show Gist options
  • Select an option

  • Save met/ed394f9cc1d738d7e0f6d968b9c1793f to your computer and use it in GitHub Desktop.

Select an option

Save met/ed394f9cc1d738d7e0f6d968b9c1793f to your computer and use it in GitHub Desktop.
Monitoring important numbers
import requests
from bs4 import BeautifulSoup
import re
from decimal import Decimal
HEADERS = {
"User-Agent": "Mozilla/5.0 (compatible; DonationComparer/1.0)"
}
def parse_amount(text: str) -> Decimal:
"""
Převede text typu '123 456 789 Kč' nebo '1,234,567 zł'
na Decimal
"""
numbers = re.sub(r"[^\d]", "", text)
return Decimal(numbers)
def get_zbrane_pro_ukrajinu():
url = "https://www.zbraneproukrajinu.cz/kampane/sos"
r = requests.get(url, headers=HEADERS, timeout=10)
r.raise_for_status()
soup = BeautifulSoup(r.text, "html.parser")
# ⚠️ selektor je odhad – může se změnit
amount_el = soup.select_one(".campaign__amount")
if not amount_el:
raise ValueError("Nepodařilo se najít částku na zbraneproukrajinu.cz")
amount = parse_amount(amount_el.get_text())
return amount, "CZK"
def get_pomagam():
url = "https://pomagam.pl/a7emy8"
r = requests.get(url, headers=HEADERS, timeout=10)
r.raise_for_status()
soup = BeautifulSoup(r.text, "html.parser")
# Pomagam.pl má částku většinou v meta nebo výrazném span
amount_el = soup.select_one(
'.total-pledge'
)
if not amount_el:
raise ValueError("Nepodařilo se najít částku na pomagam.pl")
text = amount_el.get("content") if amount_el.name == "meta" else amount_el.get_text()
amount = parse_amount(text)
return amount, "PLN"
def get_stojime_za_prezidentem_votes() -> int:
url = "https://stojimezaprezidentem.cz/"
response = requests.get(url, timeout=10)
response.raise_for_status()
match = re.search(r'verifiedCount\s*:\s*(\d+)', response.text)
if not match:
raise ValueError("Nepodařilo se najít hodnotu verifiedCount")
return int(match.group(1))
def main():
cz_amount, cz_currency = get_zbrane_pro_ukrajinu()
pl_amount, pl_currency = get_pomagam()
#sk_amount, sk_currency = doniosk()
stojime = get_stojime_za_prezidentem_votes()
print("📊 Porovnání vybraných částek a podpisů")
print("-" * 40)
print(f"Zbraně pro Ukrajinu: {cz_amount:,} {cz_currency}")
print(f"Pomagam.pl: {pl_amount:,} {pl_currency}")
print("-" * 40)
print(f"Stojíme za prezidentem: {stojime:,} ")
print("-" * 40)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment