title: BeautifulSoup error handling when find returns NoneType
body: <p>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 they are, the error ''NoneType' object has no attribute 'text'' is returned. </p>
  
  <p>I have put in a try/except block. Currently the entire search result is skipped when one of the values is missing. What can I do to allow the missing values to be replaced with a "", or blank in the xls file I am saving to?</p>
  
  <p>My code is below:</p>
  
  <pre><code>divs = soup.find_all("div", class_="result-item standard") + soup.find_all("div", class_="result-item standard  basic-ad")     
  for div in divs:
      try:
          #item_title = " ".join(div.h2.a.text.split())
          item = div.h2.a.text.split()
          item_year = item[0]
          item_make = item[1]
  
          item_model = ""
          for i in range (2,len(item)):
              item_model = item_model + item[i] + " "
  
          item_eng = div.find("li", "item-engine").text
          item_trans = div.find("li", "item-transmission").text
          item_body = div.find("li", "item-body").text
          item_odostr = div.find("li", "item-odometer").text
          item_odo = ''.join(c for c in item_odostr if c.isdigit())
          item_pricestr = " ".join(div.find("div", "primary-price").text.split())
          item_price = ''.join(c for c in item_pricestr if c.isdigit())
          item_adtype = div.find("div", "ad-type").span.text
          #item_distance = div.find("a", "distance-from-me-link").text
          item_loc = div.find("div", "call-to-action").p.text
          item_row = (str(x),item_year,item_make,item_model,item_eng,item_trans,item_body,item_odo,item_price,item_adtype,item_loc)
          print ",".join(item_row)
          print(" ")
  
          for i in range(len(item_row)):
              ws.write(x,i,item_row[i])
  
          if x % 500 == 0 :
              wb.save("data.xls")
  
  
      except AttributeError as e:
          with open("error"+str(x)+".txt", "w+") as error_file:
              error_file.write(div.text.encode("utf-8"))      
  </code></pre>