Skip to content

Instantly share code, notes, and snippets.

@frodopwns
Created December 19, 2013 01:25
Show Gist options
  • Save frodopwns/8032779 to your computer and use it in GitHub Desktop.
Save frodopwns/8032779 to your computer and use it in GitHub Desktop.
gets the cny to usd exchange rate
import requests
url = 'http://www.webservicex.net/currencyconvertor.asmx/ConversionRate?FromCurrency=CNY&ToCurrency=USD'
r = requests.get(url)
data = r.text
data = data.split("\n")[1]
spos = data.find('">') + 2
epos = data.find("</", spos)
xrate = float(data[spos:epos])
print xrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment