#!/usr/bin/env python3 """HRS handball harvester.""" import sys sys.path.insert(0, '/opt/pgz-sport/scripts/sport_harvesters') from __base import SportHarvester class HRSHarvester(SportHarvester): SPORT = 'rukomet' SOURCE = 'hrs' def scrape_klub(self, page, klub): url = f"https://hrs.hr/?s={klub['naziv'].replace(' ','+')}" self.log(f" 🤾 Klub {klub['id']} {klub['naziv']}") try: page.goto(url, wait_until="domcontentloaded", timeout=20000) # Find natjecanje or klub link links = page.locator('a[href*="hrs.hr"]').all() for a in links[:5]: href = a.get_attribute('href') or '' if 'natjecanje' in href or 'klub' in href: self.log(f" Found: {href}") break except Exception as e: self.log(f" ❌ {e}") if __name__ == '__main__': HRSHarvester().run(limit=int(sys.argv[1]) if len(sys.argv) > 1 else 50)