From 863322d0af11227f23d27dea0107938a7f11c51d Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Sun, 10 Sep 2017 17:12:10 +0200 Subject: [PATCH] Update to python api test and stations requests --- apitest/tests/a-test.py | 5 ++++- stations.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apitest/tests/a-test.py b/apitest/tests/a-test.py index a5f99a0..71d0aad 100644 --- a/apitest/tests/a-test.py +++ b/apitest/tests/a-test.py @@ -3,7 +3,6 @@ import xml.etree.ElementTree as ET import re - tree = ET.parse('respons.xml') response = root = tree.getroot() @@ -28,3 +27,7 @@ for c in n: print c.tag, c.attrib, len(c), c.text station_names = [n[0].text for n in result] + +p = re.compile('.*B.*') +matching_station_names = [n[0].text for n in result if p.match(n[0].text)] +print matching_station_names diff --git a/stations.py b/stations.py index 130d3b3..2d0954e 100644 --- a/stations.py +++ b/stations.py @@ -25,7 +25,7 @@ def get_train_stations (): """ conn = httplib.HTTPConnection(BASE_URL, PORT) - conn.request("POST", "", xml_request, HEADERS) + conn.request("POST", BASE_URL, xml_request, HEADERS) response = conn.getresponse() print response.status, response.reason # 303 Found xml_data = response.read() -- 2.39.5