from requests import get import re def getHolidays(request): try: site = get("https://calend.online/holiday/").text site = site.partition('')[0] patterns = [ r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r']*>', r'\b\d+\s+(?:лет|года)\b' ] for pattern in patterns: site = re.sub(pattern, '', site) while " " in site: site = site.replace(" ", "") things = list(set(site.split("\n"))) things.pop(0) return {"status": "pass", "details": {"code": 200, "result": '\n'.join(things)}} except Exception as e: print(e) return {"status": "error", "details": {"error_code": 500, "error_details": str(e)}}, 500