JSON and Scraping
import requests
from bs4 import BeautifulSoup
stock = input('Stock Ticker? ').lower()
while stock != 'quit' and stock != 'exit':
# Query for the HTML
data = requests.get('http://www.marketwatch.com/investing/stock/' + stock)
soup = BeautifulSoup(data.text,'html.parser')
# Get all H2 tags
h2s = soup.find_all('h2')
# Find the H2 tag with 'class=intraday__price'
for h2 in h2s:
h2class = h2.get('class')[0] # a list of classes, check first one
if h2class == 'intraday__price':
tag = h2.find('bg-quote')
print(stock.upper() + ' current price: $' + tag.text)
break
stock = input('Stock Ticker? ').lower()