Skip to content

Instantly share code, notes, and snippets.

@kylelk
Created December 28, 2013 07:18
Show Gist options
  • Save kylelk/8156923 to your computer and use it in GitHub Desktop.
Save kylelk/8156923 to your computer and use it in GitHub Desktop.
Python script to get the bitcoin block chain.
import urllib, json, time
url = "http://blockchain.info/rawblock/"
hash = "0000000000000000d621e4c3182eb6015369fc156d5ce28e0b929da54d1c745a"
for _ in range(20):
r = urllib.urlopen(url+hash)
data = json.loads(r.read())
index = str(data["block_index"])
hash = str(data["prev_block"])
open("chain/"+index+".txt", "w").write(str(data))
print index
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment