@@ -40,16 +40,20 @@ def handle(self, *args, **kwargs):
4040 independent = True
4141 ).exclude (iso3 = "COK" ):
4242 country_iso3 = country .iso3
43+ logger .info (f'Importing country { country_iso3 } ' )
4344 for indicator in world_bank_indicators :
4445 page = 1 # Reset the page for each indicator
4546 while True :
46- response = requests .get (f'https://api.worldbank.org/v2/country/{ country_iso3 } /indicator/{ indicator } ?date={ daterange } ' , params = {
47+ try :
48+ response = requests .get (f'https://api.worldbank.org/v2/country/{ country_iso3 } /indicator/{ indicator } ?date={ daterange } ' , params = {
4749 'format' : 'json' ,
4850 'source' : 2 ,
4951 'per_page' : 5000 - 1 , # World Bank throws error on 5000
5052 'page' : page ,
51- })
52- response .raise_for_status ()
53+ })
54+ except requests .exceptions .HTTPError as err :
55+ print (err .response .text )
56+ continue
5357 try :
5458 data_list = response .json ()[1 ]
5559 if data_list is not None and len (data_list ) > 0 :
@@ -73,7 +77,6 @@ def handle(self, *args, **kwargs):
7377 existing_data = next ((data for data in country_dict [geo_id ] if data [2 ] == indicator ), None )
7478 if existing_data is None or existing_data [1 ] < year :
7579 country_dict [geo_id ].append ((pop , year , indicator ))
76- print (country_dict )
7780 logger .info (json .dumps (country_dict ))
7881 if 'pages' in response .json ()[0 ]:
7982 if page >= response .json ()[0 ]['pages' ]:
0 commit comments