Skip to content

Instantly share code, notes, and snippets.

@sharuzzaman
Created September 22, 2017 15:37
Show Gist options
  • Save sharuzzaman/fef5b9a2be8f415d5a35b84f58d9a2f9 to your computer and use it in GitHub Desktop.
Save sharuzzaman/fef5b9a2be8f415d5a35b84f58d9a2f9 to your computer and use it in GitHub Desktop.
BTC last price
#!/bin/env python
import urllib2
import json
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0')]
rawdata = opener.open('https://cex.io/api/ticker/BTC/USD')
data = rawdata.read()
items = json.loads(data)
print items['last']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment