So I finally find a relevant example in the docs:
<http://docs.python.org/py3k/library/urllib.request.html?highlight=urllib#examples>

The first example gave me some understanding and led me to revising my code to

import urllib.request
f = 
urllib.request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN')
a = f.read(20500).decode('utf-8')
b = a[19000:20500]
idx_pricewrap = b.find('pricewrap')
context = b[idx_pricewrap:idx_pricewrap+80]
idx_bgLast = context.find('bgLast')
rate = context[idx_bgLast+8:idx_bgLast+15]
print(rate)

which works like a charm.

Dick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to