Last active
December 24, 2015 10:59
Bitcoin Data Archiver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
from time import sleep | |
from datetime import datetime | |
TIME_INTERVAL = 900 # 15 minutes | |
def pull_page(name, folder_name, file_ext, pull_url): | |
print("Pulling {0}...".format(name)) | |
outfile = folder_name + "/" + folder_name + "_" + str(datetime.utcnow()).replace(' ', '_') + file_ext | |
urllib.urlretrieve(pull_url, filename=outfile) | |
print("Saved to {0}...".format(outfile)) | |
while True: | |
# Unlimited | |
pull_page("Mt.Gox BTC/USD", "mtgox_btcusd", ".json", "http://data.mtgox.com/api/2/BTCUSD/money/ticker?pretty") | |
pull_page("CryptoCoin Charts", "cryptocoincharts_index", ".html", "http://www.cryptocoincharts.info/") | |
pull_page("Cryptsy", "cryptsy_index", ".html", "https://www.cryptsy.com/") | |
# Dunno | |
pull_page("Bter LTC/BTC", "bter_LTC_BTC", ".json", "https://bter.com/api/1/ticker/ltc_btc") | |
pull_page("Bter TRC/BTC", "bter_TRC_BTC", ".json", "https://bter.com/api/1/ticker/trc_btc") | |
pull_page("Bter PPC/BTC", "bter_PPC_BTC", ".json", "https://bter.com/api/1/ticker/ppc_btc") | |
pull_page("Bter XPM/BTC", "bter_XPM_BTC", ".json", "https://bter.com/api/1/ticker/xpm_btc") | |
pull_page("Bter FTC/BTC", "bter_FTC_BTC", ".json", "https://bter.com/api/1/ticker/ftc_btc") | |
# 15 Minutes | |
pull_page("Bitcoin Charts", "bitcoincharts_market", ".json", "http://api.bitcoincharts.com/v1/markets.json") | |
print("Sleeping for {0} seconds...".format(TIME_INTERVAL)) | |
sleep(TIME_INTERVAL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment