Bitcoin Forum
May 26, 2024, 08:33:06 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Bounty] 0.015 BTC for whoever can help with Python[Closed]  (Read 629 times)
Mooshire (OP)
Sr. Member
****
Offline Offline

Activity: 322
Merit: 250



View Profile
November 12, 2013, 03:10:13 AM
Last edit: November 12, 2013, 04:01:43 AM by Mooshire
 #1

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!

meta.p02
Full Member
***
Offline Offline

Activity: 196
Merit: 100



View Profile
November 12, 2013, 03:38:21 AM
 #2

https://gist.github.com/anonymous/7425079

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

Earn Devcoins by Writing | Trade on Cryptsy! Faucets: Watch ads, earn Bitcoin | Visit pages, get Bitcoin | Gamble with faucet earnings!
If you found my post informative/interesting, consider tipping at BTC: 15877457612137dj4MM57bGXRkPzU4wPRM or DVC: 1B2PAYVe9BQRrZKaWZxWtunutwrm6fVcF7.
octopus
Member
**
Offline Offline

Activity: 103
Merit: 10


View Profile
November 12, 2013, 04:03:25 AM
 #3

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 Smiley 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)

EXPd9PQ
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
November 12, 2013, 04:04:51 AM
 #4

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
meta.p02
Full Member
***
Offline Offline

Activity: 196
Merit: 100



View Profile
November 12, 2013, 04:14:08 AM
 #5

Received! Thanks, Mooshire.

Earn Devcoins by Writing | Trade on Cryptsy! Faucets: Watch ads, earn Bitcoin | Visit pages, get Bitcoin | Gamble with faucet earnings!
If you found my post informative/interesting, consider tipping at BTC: 15877457612137dj4MM57bGXRkPzU4wPRM or DVC: 1B2PAYVe9BQRrZKaWZxWtunutwrm6fVcF7.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!