from bs4 import BeautifulSoup
from park_api.util import convert_date
from park_api.geodata import GeoData

# This loads the geodata for this city if <city>.geojson exists in the same directory as this file.
# No need to remove this if there's no geodata (yet), everything will still work.
geodata = GeoData(__file__)

# This function is called by the scraper and given the data of the page specified as source in geojson above.
# It's supposed to return a dictionary containing everything the current spec expects. Tests will fail if it doesn't ;)
def parse_html(html):

    # BeautifulSoup is a great and easy way to parse the html and find the bits and pieces we're looking for.
    soup = BeautifulSoup(html, "html.parser")

    # last_updated is the date when the data on the page was last updated, it should be listed on most pages
    #   suche: <p class="updateinfo">zuletzt aktualisiert: 28.05.2019 15.30 Uhr</p>
    updated = soup.find( "p", class_="updateinfo")
    last_updated = datetime.datetime.strptime(updated.text, 'zuletzt aktualisiert: %d.%m.%Y %H.%M Uhr')

    data = {
        # convert_date is a utility function you can use to turn this date into the correct string format
        "last_updated": convert_date(last_updated.text, "%d.%m.%Y %H:%M Uhr"),
        # URL for the page where the scraper can gather the data
        "lots": []
    }

    parking_lots = soup.find_all("div", class_="accordeon parkmoeglichkeit")
    for one_lot in parking_lots :
        parking_name = one_lot.find("h3").text
        lot = geodata.lot(parking_name)

        parking_state = 'open'
        parking_free = 0
        try :
            parking_belegung=one_lot.find("div", class_="belegung")
            if (parking_belegung != None ) :
                parking_free=int(parking_belegung.find("strong").text)
        except :
            parking_state='nodata'

        data["lots"].append({
            "name": lot.name,
            "free": parking_free,
            "total": lot.total,
            "address": lot.address,
            "coords": lot.coords,
            "state": parking_state,
            "lot_type": lot.type,
            "id": lot.id,
            "forecast": False,
        })

    return data

from bs4 import BeautifulSoup
from park_api.util import convert_date
from park_api.geodata import GeoData
import datetime

# This loads the geodata for this city if <city>.geojson exists in the same directory as this file.
# No need to remove this if there's no geodata (yet), everything will still work.
geodata = GeoData(__file__)

# This function is called by the scraper and given the data of the page specified as source in geojson above.
# It's supposed to return a dictionary containing everything the current spec expects. Tests will fail if it doesn't ;)
def parse_html(html):

    # BeautifulSoup is a great and easy way to parse the html and find the bits and pieces we're looking for.
    soup = BeautifulSoup(html, "html.parser")

    # last_updated is the date when the data on the page was last updated, it should be listed on most pages
    #   suche: <p class="updateinfo">zuletzt aktualisiert: 28.05.2019 15.30 Uhr</p>
    updated = soup.find( "p", class_="updateinfo")
    last_updated = datetime.datetime.strptime(updated.text, 'zuletzt aktualisiert: %d.%m.%Y %H.%M Uhr')

    data = {
        # convert_date is a utility function you can use to turn this date into the correct string format
        "last_updated": convert_date(last_updated.text, "%d.%m.%Y %H:%M Uhr"),
        # URL for the page where the scraper can gather the data
        "lots": []
    }

    parking_lots = soup.find_all("div", class_="accordeon parkmoeglichkeit")
    for one_lot in parking_lots :
        parking_name = one_lot.find("h3").text
        lot = geodata.lot(parking_name)

        parking_state = 'open'
        parking_free = 0
        try :
            parking_belegung=one_lot.find("div", class_="belegung")
            if (parking_belegung != None ) :
                parking_free=int(parking_belegung.find("strong").text)
        except :
            parking_state='nodata'

        data["lots"].append({
            "name": lot.name,
            "free": parking_free,
            "total": lot.total,
            "address": lot.address,
            "coords": lot.coords,
            "state": parking_state,
            "lot_type": lot.type,
            "id": lot.id,
            "forecast": False,
        })

    return data

Update Regensburg.py