From bac7070686b3c8d1871466a29a6cbee4d53f05d7 Mon Sep 17 00:00:00 2001 From: bergi Date: Mon, 3 Jan 2022 22:19:22 +0100 Subject: [PATCH] (#4) add Ulm scraper --- web/scrapers/builtin/original/ulm.geojson | 185 ++++++++++++++++++++++ web/scrapers/builtin/original/ulm.py | 55 +++++++ 2 files changed, 240 insertions(+) create mode 100644 web/scrapers/builtin/original/ulm.geojson create mode 100644 web/scrapers/builtin/original/ulm.py diff --git a/web/scrapers/builtin/original/ulm.geojson b/web/scrapers/builtin/original/ulm.geojson new file mode 100644 index 0000000..9f8b3a8 --- /dev/null +++ b/web/scrapers/builtin/original/ulm.geojson @@ -0,0 +1,185 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "id": "ulmamrathaus", + "name": "Am Rathaus", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Neue Str. 113", + "capacity": 558, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.993047, + 48.397305 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmcongresscentrumnordbasteicenter", + "name": "Congress Centrum Nord / Basteicenter", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Wichernstraße", + "capacity": 420, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 10.001591, + 48.401814 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmcongresscentrumsuedmaritimhotel", + "name": "Congress Centrum Süd / Maritim Hotel", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Basteistraße 46", + "capacity": 235, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 10.004385, + 48.401223 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmdeutschhaus", + "name": "Deutschhaus", + "type": "garage", + "public_url": null, + "source_url": null, + "address": "Friedrich-Ebert-Straße 8", + "capacity": 594, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.984545, + 48.397917 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmfischerviertel", + "name": "Fischerviertel", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Schwilmengasse", + "capacity": 395, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.988355, + 48.396583 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmfrauenstrasse", + "name": "Frauenstraße", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Rosengasse 19", + "capacity": 770, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.996022, + 48.400979 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmkornhaus", + "name": "Kornhaus", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Rosengasse 9", + "capacity": 135, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.99491, + 48.40093 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmsalzstadel", + "name": "Salzstadel", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Salzstadelgasse 14", + "capacity": 530, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.990002, + 48.40116 + ] + } + }, + { + "type": "Feature", + "properties": { + "id": "ulmtheater", + "name": "Theater", + "type": "underground", + "public_url": null, + "source_url": null, + "address": "Olgastraße 63", + "capacity": 83, + "has_live_capacity": false + }, + "geometry": { + "type": "Point", + "coordinates": [ + 9.98559, + 48.40062 + ] + } + } + ] +} \ No newline at end of file diff --git a/web/scrapers/builtin/original/ulm.py b/web/scrapers/builtin/original/ulm.py new file mode 100644 index 0000000..0162af2 --- /dev/null +++ b/web/scrapers/builtin/original/ulm.py @@ -0,0 +1,55 @@ +""" +Original code and data by Quint +""" +from typing import List + +from util import * + + +class Ulm(ScraperBase): + + POOL = PoolInfo( + id="ulm", + name="Ulm", + public_url="https://www.parken-in-ulm.de/", + source_url=None, + timezone="Europe/Berlin", + attribution_contributor="Ulmer Parkbetriebs-GmbH", + attribution_license=None, + attribution_url="https://www.parken-in-ulm.de/impressum.php", + ) + + def get_lot_data(self) -> List[LotData]: + timestamp = self.now() + soup = self.request_soup(self.POOL.public_url) + + lots = [] + + table = soup.find('table', id='haupttabelle') + table2 = table.find('table', width='790') + rows = table2.find_all('tr') + for row in rows[3:12]: + parking_data = row.find_all('td') + parking_name = parking_data[0].text + + try: + parking_state = LotData.Status.open + parking_free = int(parking_data[2].text) + except: + parking_free = None + parking_state = LotData.Status.nodata + + lots.append( + LotData( + timestamp=timestamp, + id=name_to_legacy_id("ulm", parking_name), + status=parking_state, + num_free=parking_free, + capacity=int_or_none(parking_data[1].text), + ) + ) + + return lots + + def get_lot_infos(self) -> List[LotInfo]: + return self.get_v1_lot_infos_from_geojson("Ulm")