From 89cf36c357793fa3a6cc2ecdad9bd0fa14105205 Mon Sep 17 00:00:00 2001 From: Chris Berkhout Date: Tue, 4 May 2021 17:25:42 +0200 Subject: [PATCH] Don't bother using XML namespaces for ECB data. --- src/pricehist/sources/ecb.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pricehist/sources/ecb.py b/src/pricehist/sources/ecb.py index 034c7e6..0e6a668 100644 --- a/src/pricehist/sources/ecb.py +++ b/src/pricehist/sources/ecb.py @@ -1,7 +1,6 @@ from datetime import datetime, timedelta from decimal import Decimal from lxml import etree -from lxml.cssselect import CSSSelector import requests @@ -92,14 +91,13 @@ class ECB: data = response.content root = etree.fromstring(data) - ns = {"default": "http://www.ecb.int/vocabulary/2002-08-01/eurofxref"} all_rows = [] - for day in CSSSelector("default|Cube[time]", ns)(root): + for day in root.cssselect("[time]"): date = day.attrib["time"] # TODO what if it's not found for that day? # (some quotes aren't in the earliest data) - for row in CSSSelector(f"default|Cube[currency='{quote}']", ns)(day): + for row in day.cssselect(f"[currency='{quote}']"): rate = Decimal(row.attrib["rate"]) all_rows.insert(0, (date, rate)) selected = [