python 获取美元实际汇率

def get_money():

	import re
	import json
	import urllib.request

	url = "http://webforex.hermes.hexun.com/forex/quotelist?code=FOREXUSDCNY&column=Code,Price"

	headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}
	req = urllib.request.Request(url=url, headers=headers)
	f=urllib.request.urlopen(req).read()

	html = f
	s = re.findall("{.*}",str(html))[0]
	sjson = json.loads(s)
	USDCNY = float(sjson["Data"][0][0][1]/10000)
	return USDCNY

  

原文地址:https://www.cnblogs.com/zhangshijiezsj/p/14211458.html