I'm following Sentdex' tutorials for mathplotlib, and i'm stuck at this video: #8 getting data from the internet: https://www.youtube.com/watch?v=IbUa1tTT-7k&t=625s
the provided code looks like this:
import matplotlib.pyplot as plt
import numpy as np
import urllib
import matplotlib.dates as mdates
def graph_data(stock):
stock_price_url = http://chartapi.finance.yahoo.com/instrument/1.0/'+stock+'/chartdata;type=quote;range=10y/csv'
source_code = urllib.request.urlopen(stock_price_url).read().decode()
stock_data = []
split_source = source_code.split('\n')
for line in split_source:
split_line = line.split(',')
if len(split_line) == 6:
if 'values' not in line:
stock_data.append(line)
Apparently the yahoo.api doesn't work anymore. I tried to find some different source, but if I use another url, I get an 'invalid character' error in any case.
I also tried urllib3 and couldn't/shouldn't I use the requests module?
I don't care if it's finance, sports or weather data, but I'd be glad, if I could continue with this tutorial, or if you could point out a better alternative.