-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#4) add Limburg scraper - fidgeted with the status and numbers a bit
- Loading branch information
Showing
2 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgaltstadt", | ||
"name": "Altstadt", | ||
"type": "underground", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Sackgasse 11", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.063018, | ||
50.388892 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgbahnhof", | ||
"name": "Bahnhof", | ||
"type": "garage", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Graupfortstraße 7", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.0641, | ||
50.385133 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgcity", | ||
"name": "City", | ||
"type": "garage", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Frankfurter Straße 12", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.066296, | ||
50.386418 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgkarstadt", | ||
"name": "Karstadt", | ||
"type": "garage", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Werner-Senger-Straße 15", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.060811, | ||
50.38682 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgphmitte", | ||
"name": "PH-Mitte", | ||
"type": "garage", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Grabenstraße 26", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.062045, | ||
50.388618 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgsparkasse", | ||
"name": "Sparkasse", | ||
"type": "garage", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Schiede 41", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.059188, | ||
50.387296 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgstadthalle", | ||
"name": "Stadthalle", | ||
"type": "garage", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Diezer Straße 17", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.061152, | ||
50.387457 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"id": "limburgwerkstadt", | ||
"name": "WERKStadt", | ||
"type": "lot", | ||
"public_url": null, | ||
"source_url": null, | ||
"address": "Joseph-Schneider-Straße 1", | ||
"capacity": 0, | ||
"has_live_capacity": true | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
8.056576, | ||
50.384046 | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
""" | ||
Original code and data by Quint | ||
""" | ||
from typing import List | ||
|
||
from util import * | ||
|
||
|
||
class Limburg(ScraperBase): | ||
|
||
POOL = PoolInfo( | ||
id="limburg", | ||
name="Limburg", | ||
public_url="https://www.limburg.de/Verkehr/Parken", | ||
source_url="https://p127393.mittwaldserver.info/LM/_pls/pls.php", | ||
timezone="Europe/Berlin", | ||
attribution_contributor="Stadt Limburg", | ||
attribution_license=None, | ||
attribution_url=None, | ||
) | ||
|
||
def get_lot_data(self) -> List[LotData]: | ||
timestamp = self.now() | ||
soup = self.request_soup(self.POOL.source_url) | ||
|
||
last_updated = self.to_utc_datetime(soup.find('b').text, 'Stand: %d.%m.%Y %H:%M:%S Uhr') | ||
lots = [] | ||
|
||
entries = soup.find('table', class_='tabellenformat') | ||
entries_rows = entries.find_all('tr') | ||
# first line: header | ||
for one_entry in entries_rows[1:]: | ||
one_entry_data = one_entry.find_all('td') | ||
if len(one_entry_data) < 6: | ||
continue | ||
|
||
parking_name = one_entry_data[0].text.strip() | ||
parking_free = None | ||
parking_total = None | ||
parking_status = LotData.Status.unknown | ||
|
||
if one_entry_data[5].text == 'Offen': | ||
parking_status = LotData.Status.open | ||
elif one_entry_data[5].text == 'Geschlossen': | ||
parking_status = LotData.Status.closed | ||
|
||
try: | ||
parking_total = int(one_entry_data[1].text) | ||
parking_free = int(one_entry_data[3].text) | ||
except: | ||
parking_status = LotData.Status.nodata | ||
|
||
# avoid storing zeros when lot is closed | ||
if parking_status == LotData.Status.closed: | ||
if not parking_free: | ||
parking_free = None | ||
if not parking_total: | ||
parking_total = None | ||
|
||
lots.append( | ||
LotData( | ||
timestamp=timestamp, | ||
lot_timestamp=last_updated, | ||
id=name_to_legacy_id("limburg", parking_name), | ||
status=parking_status, | ||
num_free=parking_free, | ||
capacity=parking_total, | ||
) | ||
) | ||
|
||
return lots | ||
|
||
def get_lot_infos(self) -> List[LotInfo]: | ||
return self.get_v1_lot_infos_from_geojson( | ||
"Limburg", | ||
defaults={ | ||
"has_live_capacity": True, | ||
} | ||
) |