Feb-21-2019, 05:34 PM
(This post was last modified: Feb-21-2019, 05:34 PM by rudolphyaber.)
I'm using python 3.6 on Windows 7 and I'm following the directions on this page -> https://medium.freecodecamp.org/how-to-s...46935d93fe but I continue getting errors. I'm currently getting this error: AttributeError: 'NoneType' object has no attribute 'text'
Here's my code:
Here's my code:
#import libraries
import urllib
import urllib.request
from bs4 import BeautifulSoup
#specify the url
quote_page = 'https://www.bloomberg.com/quote/SPX:IND'
#query the website and return the html to the variable 'page'
page = urllib.request.urlopen(quote_page)
#parse the html using beautiful soup and store in variable 'soup'
soup = BeautifulSoup(page, 'html.parse')
#Take out the <div> of name and get its value
name_box = soup.find('h1', attr={'class': 'name'})
name = name_box.text.strip() # strip() is used to remove starting & trailing
print(name)
