Bitcoin Forum

Economy => Services => Topic started by: Mooshire on November 12, 2013, 03:10:13 AM



Title: [Bounty] 0.015 BTC for whoever can help with Python[Closed]
Post by: Mooshire on November 12, 2013, 03:10:13 AM
I need to retrieve the last price from https://api.bitcoinaverage.com/no-mtgox/ticker/USD in a python script, then have it change the contents of a text file to the price. Couldn't do it myself.
Bonus 0.005 if it runs every 30 seconds to keep it updated. (It can stay running). (I would really prefer that it updates every 30 seconds)

EDIT: I will escrow if needed.

EDIT: Python 3.3.2

Someone in the JD chatroom claimed it. Thanks!


Title: Re: [Bounty] 0.015 BTC for whoever can help with Python
Post by: meta.p02 on November 12, 2013, 03:38:21 AM
https://gist.github.com/anonymous/7425079

See if it works on Python 3.3.2 (since I only have 2.7.4)


Title: Re: [Bounty] 0.015 BTC for whoever can help with Python[Closed]
Post by: octopus on November 12, 2013, 04:03:25 AM
Code:
import urllib
import re

link = "https://api.bitcoinaverage.com/no-mtgox/ticker/USD"
f = urllib.urlopen(link)
myfile = f.read()
last = re.search("last\": (.+?),", myfile).group(1)
myFile = open('last.txt', 'w')
myFile.write(last)
myFile.close()

custom tailored :) 1C2NWeHxtaGyo9keSLwNMYXSsDBYwhMgaE

edit:

self-updating:

Code:
import urllib
import re
import time

while True:
        link = "https://api.bitcoinaverage.com/no-mtgox/ticker/USD"
        f = urllib.urlopen(link)
        myfile = f.read()
        last = re.search("last\": (.+?),", myfile).group(1)
        myFile = open('last.txt', 'w')
        myFile.write(last)
        myFile.close()
        print "updated: %s" % last
        time.sleep(30)


Title: Re: [Bounty] 0.015 BTC for whoever can help with Python[Closed]
Post by: EXPd9PQ on November 12, 2013, 04:04:51 AM
Works in 2.7 for me:
https://gist.github.com/anonymous/862695cafa58a7a1d581

Should work in 3.3:
https://gist.github.com/anonymous/245e8a507a502fd5b860

Guess I'm late though. Just in case -> 1AiKrzcbppKdD8T2vN27hf1UFZ25V8ZbQm


Title: Re: [Bounty] 0.015 BTC for whoever can help with Python[Closed]
Post by: meta.p02 on November 12, 2013, 04:14:08 AM
Received! Thanks, Mooshire.