I need your help to extract/scrape the “Dollar Index” from this website: Netdania's Live Streaming Currency Rates Foreign Exchange
Or this page: Netdania's Full Quote
I’m a beginner in Python and have tried to modify the scripts I can find with Google without success. I can use the code below to get the present value (which is what I need) from another website, but I’m not able to use it for the site mentioned above. Why is that?
# python 2.7
import urllib
import re
htmlfile = urllib.urlopen('http://finance.yahoo.com/q?s=EURUSD=X')
htmltext = htmlfile.read()
regex = '<span id="yfs_p20_eurusd=x">(.+?)</span>'
pattern = re.compile(regex)
price = re.findall(pattern, htmltext)
print price
price2 = ':'.join(price)
print price2
def get_num(x):
return int(''.join(ele for ele in x if ele.isdigit()))
price3 = get_num(price2)
print price3