aaronlolz (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
|
April 23, 2013, 08:35:01 PM |
|
Ive never used python before, and found 2 peerbet scripts that automaticly place bets idk how to run them though maybe some help? please be very descriptive. import cookielib, urllib2,urllib,random,time,sys,traceback,StringIO,gzip
def call(opener,url,params=None): time.sleep(1) url=url+'&compress=1' if params is not None: uri=url+"&"+params else: uri=url try: opener.addheaders=[("Accept-Encoding", "gzip")] # print uri f=opener.open(uri) response=f.read() except urllib2.URLError: time.sleep(random.uniform(1,5)) return call(opener,url,params) read=f.info().getheader("Content-Encoding") if read=='gzip': sio = StringIO.StringIO(response) sio.seek(0) gz=gzip.GzipFile(None,mode='rb',fileobj=sio) response= gz.read() gz.close() sio.close() # print response if response is None: return call(opener,url,params) else: try: read=eval(response) except: print '>>> traceback <<<' traceback.print_exc() print '>>> end of traceback <<<' time.sleep(random.uniform(1,5)) return call(opener,url,params)
error=None try: error= read['error'] print "|",error,"|" except: return read if 'limit' in str(error): time.sleep(random.uniform(1,5)) return call(opener,url,params) else: raise NameError(error)
def login(opener): global password global username params = urllib.urlencode({'username': username, 'password': password}) print "login",call(opener,'https://peerbet.org/api.php?method=login',params)
if sys.argv[1] is not None: username=sys.argv[1] if sys.argv[2] is not None: password=sys.argv[2]
while True: try: cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) params = urllib.urlencode({'username': username, 'password': password}) print call(opener,"https://peerbet.org/api.php?method=login",params)
params = urllib.urlencode({'message': 'satoshi'}) message=call(opener,"https://peerbet.org/api.php?method=postchatmessage",params) print message['message_id'];
except: print '>>> traceback <<<' traceback.print_exc() print '>>> end of traceback <<<' time.sleep(random.uniform(60*60,2*60*60))
and import cookielib, urllib2,urllib,random,time
cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) params = urllib.urlencode({'username': '', 'password': ''}) r = opener.open("https://peerbet.org/api.php?method=login&%s" % params) print r.read()
max_lose=10 ticketpricebase=0.0000023 ticketprice=ticketpricebase lose_count=0;
while True:
f = opener.open("https://peerbet.org/api.php?method=getuserinfo") userinfo=f.read() userinfo=eval(userinfo) print 'balance:' + str(userinfo['balance']); if ticketprice>userinfo['balance']: break else: params = urllib.urlencode({'tickets': '2', 'price': ticketprice,'expire':'1','instant':'1'}) raffle=opener.open('https://peerbet.org/api.php?method=createraffle&%s' % params) raf= raffle.read() raf=eval(raf) raffleid=raf['raffle_id']
params = urllib.urlencode({'raffle': raffleid, 'tickets': 1}) opener.open('https://peerbet.org/api.php?method=buytickets&%s' % params) print str(raffleid) + ':' + str(ticketprice)
while True: params = urllib.urlencode({'raffle': raffleid}) f=opener.open('https://peerbet.org/api.php?method=getraffleinfo&%s' % params) raffle=f.read() raffle=eval(raffle) if raffle['status']=='win': ticketprice=ticketpricebase print 'win' lose_count=0 time.sleep(10) break elif raffle['status']=='lose': lose_count+=1 ticketprice*=random.uniform(2, 3) print 'lose' if lose_count>=max_lose: lose_count=0 time.sleep(random.uniform(60*60, 2*60*60)) break time.sleep(1)
|