Skip to content Skip to sidebar Skip to footer

BeautifulSoup Error Handling When Find Returns NoneType

I am scraping search results from a website where each result is contained in a and has a range of data associated with it. However some of these data values are missing and when

Solution 1:

for example:

item_eng = div.find("li", "item-engine").text if div.find("li", "item-engine") else ''

or:

item_eng = div.find("li", "item-engine").text if len(div.find_all("li", "item-engine"))!=0 else ''

Post a Comment for "BeautifulSoup Error Handling When Find Returns NoneType"