I am creating a web scraping python code (using 2.7.11) that extracts the stock price using symbol. I am not sure why this is not working. But it gives me this output:
Enter Financial Symbol
appl YPE h
Do you want to run again?
My code is below:
import urllib
go=True
while go:
print "Enter Financial Symbol"
symbol=raw_input()
page=urllib.urlopen("http://finance.yahoo.com/q?s=" + symbol)
text=page.read()
where=text.find("yfs_l84")
start=where+7
end=start+5
result = text[start:end]
print ( symbol + " "+ result)
print "Do you want to run again?"
choice=raw_input()
if choice == "no":
go=False
How do I make it work?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…