I am using python 3 to scrape a website and print a value. Here is the code
import urllib.request
import re
url = "http://in.finance.yahoo.com/q?s=spy"
hfile = urllib.request.urlopen(url)
htext = hfile.read().decode('utf-8')
regex = '<span id="yfs_l84_SPY">(.+?)</span>'
code = re.compile(regex)
price = re.findall(code,htext)
print (price)
when i run this snippet, it prints an empty list, ie. []
, but i am expecting a value e.g. 483.33
.
What is the thing that i am getting wrong ? Help