- if (doc["type"] == "img") or \
- ((doc["type"] == "html_element") and (doc["value"] == "img")):
- result.append({'alt': doc['attr']['alt'], 'src': doc['attr']['src']})
+ if (doc['type'] == 'img') or \
+ ((doc['type'] == 'html_element') and (doc['value'] == 'img')):
+ alt = doc['attr'].get('alt', '')
+ result.append({'alt': alt, 'src': doc['attr']['src']})