Skip to content

Commit

Permalink
(#4) add Ulm scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
defgsus committed Jan 3, 2022
1 parent 8b5238b commit bac7070
Show file tree
Hide file tree
Showing 2 changed files with 240 additions and 0 deletions.
185 changes: 185 additions & 0 deletions web/scrapers/builtin/original/ulm.geojson
Original file line number Diff line number Diff line change
@@ -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
]
}
}
]
}
55 changes: 55 additions & 0 deletions web/scrapers/builtin/original/ulm.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit bac7070

Please sign in to comment.