Skillerz' Script seems to be non-functional as of now. So i took some time off today and wrote a CGI script in python to do exactly what he has done. Later i'll be updating the HTML code inside it to auto-update and support other currency stuff through CGI Forms.
Usage is quite simple. you just upload it to a webserver, and assuming you have python-cgi enabled, it will poll the Cryptsy and BTCe for the current prices, and do the calculations.
I have this working on my notebook which has LightHTTP installed to it. If you have a VPS and want to run this script on your server, i can supply you with my configuration scripts which enable python-CGI.
If you really like this script, please donate some GLD ^o^
#!/usr/bin/python
import httplib
import urllib
import json
from decimal import *
def CryptsyTickerAPI(marketID):
# Get current Buy/Sell values for a given marketID
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
params = ''
conn = httplib.HTTPConnection('pubapi.cryptsy.com:80')
# Sometimes the connection times out (slow connections) or the network is down
# Catch the error so that the entire script doesn't crash
try:
conn.request('GET', '/api.php?method=singlemarketdata&marketid=' + str(marketID), params, headers)
response = conn.getresponse()
data = json.load(response)
buyPrice = data["return"]["markets"]["GLD"]["buyorders"][0]['price']
sellPrice = data["return"]["markets"]["GLD"]["sellorders"][0]['price']
conn.close()
return buyPrice, sellPrice
except:
TickerAPI(marketID)
# Get current Buy/Sell data
def BTCeTicker(pair):
# pair can be: ltc_usd, btc_usd, etc...
# reqType can be: ticker, trades, or depth
# Get ticker information
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
params = ''
#conn = httplib.HTTPSConnection('btc-e.com')
try:
conn = httplib.HTTPSConnection("btc-e.com")
conn.request('GET', '/api/2/' + pair + 'ticker', params, headers)
response = conn.getresponse()
data = json.load(response)
buyPrice = data['ticker']['buy']
sellPrice = data['ticker']['sell']
conn.close()
return buyPrice, sellPrice
except:
print 'Connection failure...retrying.'
BTCeTicker(pair)
LTCGLD_currentPrice = CryptsyTickerAPI(36)
LTCUSD_currentPrice = BTCeTicker('ltc_usd/')
GLDUSD_currentBuy = round(Decimal(LTCGLD_currentPrice[0]) * Decimal(LTCUSD_currentPrice[0]), 6)
GLDUSD_currentSell = round(Decimal(LTCGLD_currentPrice[1]) * Decimal(LTCUSD_currentPrice[1]), 6)
print 'Content-type:text/html\r\n\r\n'
print '<html>'
print '<head>'
print '<title>Current GLD/USD exchange Prices on Cryptsy.com</title>'
print '</head>'
print '<body>'
print '<center>Current GLD/USD exchange Prices on Cryptsy.com</center>'
print '<center>compliments of the Cryptsy and BTC-e Ticker APIs</center>'
print '<p>'
print 'Current Buy: ' + '<b>' + str(GLDUSD_currentBuy) + '</b><br>'
print 'Current Sell: ' + '<b>' + str(GLDUSD_currentSell) + '</b>'
print '<p>'
print '<p>'
print 'Note ** Later versions of this script will include an interactive CGI interface so that more alt-currencies can be used'
print '<p><p>'
print 'If you found this script useful consider donating a little bit of GLD here:<p>'
print 'ECQatb9BMuEFmPDUmMWypvFpwiMUwEv6au <p>'
print 'contact: miner007 (celtic_tigger1(a.t.)hotmail.com)'
print '</body>'
print '</html>'