Skip to content

Commit facfc35

Browse files
committed
fix crash in case of error in getting entries from dataservice page
1 parent 6615912 commit facfc35

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

knesset_data/dataservice/base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from copy import deepcopy
1111
from collections import OrderedDict
1212
import six
13+
import traceback
1314

1415

1516
logger=logging.getLogger(__name__)
@@ -292,10 +293,18 @@ def _get_all_pages(cls, start_url, params=None, proxies=None, skip_exceptions=Fa
292293
next_url = ds_utils.compose_url_get(start_url, params)
293294
while next_url:
294295
soup = cls._get_soup(next_url, proxies=proxies)
295-
for entry in soup.feed.find_all('entry'):
296+
try:
297+
entries = soup.feed.find_all('entry')
298+
except Exception:
299+
traceback.print_exc()
300+
entries = []
301+
for entry in entries:
296302
yield cls._get_instance_from_entry(entry, skip_exceptions=skip_exceptions)
297-
next_link = soup.find('link', rel="next")
298-
next_url = next_link and next_link.attrs.get('href', None)
303+
try:
304+
next_link = soup.find('link', rel="next")
305+
next_url = next_link and next_link.attrs.get('href', None)
306+
except Exception:
307+
next_url = None
299308

300309
@classmethod
301310
def get(cls, id, proxies=None):

0 commit comments

Comments
 (0)