bundesAPI / handelsregister

295 stars 33 forks source link

Bugfix: Catch IndexError on search results #20

Open tharndt opened 1 year ago

tharndt commented 1 year ago

There exist search results where the logic to collect 'history' does not apply and fails with an IndexError. A first and simple approach to this issue is to continue on IndexError and ignore corrupted information of entries.

Change the following lines in handelsregister.py...

113    for i in range(hist_start, len(cells), 3):
114       d['history'].append((cells[i], cells[i+1])) # (name, location)

...to:

113    for i in range(hist_start, len(cells), 3):
114        try:
115            d['history'].append((cells[i], cells[i+1]))  # (name, location)
116        except IndexError:  # there might be entries where this logic does not apply
117            continue

Alternatively the author(s) should have another look at the results and the parsing.