I have been using the Amazon Product API with bottlenose and when iterating over the XML response I have encountered null type errors.
I think I have half managed to handle them however it won't extract the other information if it encounters this error thus showing fewer results than there are.
Is there a way to handle this properly so all the information is extracted and the error is ignored?
price_list = [{}]
for i in price_search:
lnp = i.LowestNewPrice.FormattedPrice.text
qty_n = i.TotalNew.text
qty_u = i.TotalUsed.text
int_qty_u = int(qty_u)
if int_qty_u > 0:
lup = i.LowestUsedPrice.FormattedPrice.text
else:
continue
price_list.append({'Lowest New Price': lnp, 'Lowest Used Price': lup, 'Quantity New': qty_n, 'Quantity Used': qty_u})
In this instance it is specifically the LowestUsedPrice
, if an item doesn't have this tag then the error is raised.
I am new to Python and coding so struggling along as best I can...