I'm trying to run this code:
import time
import urllib.request
from urllib.request import urlopen
ibov = ['BBAS3.SA', 'PETR4.SA']
def yahooKeyStats(stock):
try:
sourceCode = urllib.request.urlopen ('https://finance.yahoo.com/quote/.../key-statistics?p=' +stock).read()
pl = sourceCode.split('Preço/Livro </td><td class="Fz(s) Fw(500) Ta(end)">')[1].split('</td>')[0]
print ("preço livro:", pl)
except Exception as e:
print (e)
I've checked all the possibilities and can not fix it. Sorry for the question, which may be silly, but I'm starting and I have questions.