title: Python 3 'NoneType' object has no attribute 'text'
body: <pre><code># import libraries
  from urllib.request import urlopen
  from bs4 import BeautifulSoup
  
  #specify the url
  html = 'https://www.bloomberg.com/quote/SPX:IND'
  
  # query the website and return the html to thevariable 'page'
  page = urlopen(html)
  
  # parse the html using beautiful soup and store in variable 'soup'
  data = BeautifulSoup(page, 'html.parser')
  
  #take out the &lt;div&gt; of name and get its value
  name_box = data.find('h1', attrs={'class': 'companyName_99a4824b'})
  
  name = name_box.text.strip() #strip is used to remove starting and trailing
  print (name)
  
  # get the index price
  price_box = data.find('div', attrs={'class':'priceText_1853e8a5'})
  price = price_box.text
  print (price)
  </code></pre>
  
  <p>I was following a guide on medium.com <a href="https://medium.freecodecamp.org/how-to-scrape-websites-with-python-and-beautifulsoup-5946935d93fe" rel="nofollow noreferrer">here</a> and was having some conflictions due to lacking of knowledge of python and scripting, but I think I have my error at</p>
  
  <p>name = name_box.text</p>
  
  <p>because text is not defined and I am unsure they would like me to define it using the BeautifulSoup library. Any help maybe appreciated. The actual error will be below</p>
  
  <pre><code> RESTART: C:/Users/Parsons PC/AppData/Local/Programs/Python/Python36-32/projects/Scripts/S&amp;P 500 website scraper/main.py 
  Traceback (most recent call last):
    File "C:/Users/Parsons PC/AppData/Local/Programs/Python/Python36-32/projects/Scripts/S&amp;P 500 website scraper/main.py", line 17, in &lt;module&gt;
      name = name_box.text.strip() #strip is used to remove starting and trailing
  AttributeError: 'NoneType' object has no attribute 'text'
  </code></pre>