QUOTE(sauying @ Nov 1 2017, 07:55 AM)
File 'spin.py', line 39, in <module>
if r and r["data"]:
KeyError: 'data'
what is this meaning ?
It means the link that you provided in the script is old url(api), you should update it with latest url.
QUOTE(Stormknight @ Nov 1 2017, 07:35 AM)
is the code working? so far still no voucher yet
Same, got 1 10 %, then nothing come out, maybe the voucher is finish and waiting for refuel.
---
Anyways, I post the code that I changed a bit to compatible with Python 3.x, hope the original coder don't mind.

PS: The header user-agent will be MS Edge, you can change it to different browser and Windows, just in case.
PS2: Got multi-space before the code, when you copy the code, ensure there is space in front.
Spin.
» Click to show Spoiler - click again to hide... «
CODE
import requests, time
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"}
def recursionftwdude(theSession):
try:
theSession.close()
theSession = None
theSession = requests.Session()
theSession.get("https://www.lazada.com.my/", headers=headers)
return theSession
except:
recursionftwdude(theSession)
numberOfAttempt = 0
s = requests.Session()
s.get("https://www.lazada.com.my/", headers=headers)
url = "https://www.lazada.com.my/ajax/lottery/spinTheWheel/?lang=en&platform=desktop&wheelToken=7b03cfa1ba0da7194d771e2d262f54fc&dpr=1" # the api url
while 1:
numberOfAttempt += 1
if numberOfAttempt == 1500:
s = recursionftwdude(s)
numberOfAttempt = 0
try:
r = s.get(url, headers=headers).json()
except ValueError:
print ("Server no give shit")
time.sleep(5) # give server rest, because i see 503 too often
continue
except requests.exceptions.ConnectionError:
print ("Server no give shit!!!")
time.sleep(2) # littlebit speacial
continue
try:
print ("Voucher: " + r["data"]["voucherCode"])
s = recursionftwdude(s)
with open("voucherCodeHi.txt", "a") as f: # voucher code yang dijumpa ade kat dlm file name dier voucherCodeHi.txt
f.write(time.ctime(int(time.time())) + " : " + str(r["data"]["voucherCode"]) + "\n")
except KeyError:
if r and r["data"]:
print ("Everything is normal! " + str(numberOfAttempt))
time.sleep(3) # bende baru ade kat sini/This is the one that control how long it wait until next spin
continue
View.
» Click to show Spoiler - click again to hide... «
CODE
import time
def sotar(linee):
if linee == '':
return False
for symbols in linee.split(":")[3].replace(' ', ''):
if symbols == '-':
return False
else:
return True
def main():
f = open("voucherCodeHi.txt", "r") # bukak file output
vcl = f.read().split('\n') # bahagi setiap line dalam voucher file ke dalam satu list dalam ni --> vcl
sotared = {'10':[],'11':[],'15':[],'29':[]} # tempat barang disusun
for line in vcl: # untuk loop ni kiter guna line kiter jadi ni --> Mon Oct 02 23:47:04 2017 : 5CYBERhiahia
if sotar(line): # selalunya kalu aku bukak voucher file pastu aku guner aku letak '-' kat hujung line tu mcm 'Mon Sep 11 07:01:47 2017 : 19KAWa6u98a -sedekah' nmpk ade dash kat situ, maka kalu ade dash dalam satu line tu akan membawa maksud yang bahawa voucher tu aku dah guna/ambik bagi orang
vc = line.split(":")[3].replace(' ', '') # buat line jadi ['Mon Oct 02 23', '47', '04 2017 ', '5CYBERhiahia'] pastu kiter buang space dlm vc[3](tu tempat voucher kiter tersimpan)
y = [] # bapak ah
for w in vc: # ambek setiap huruf/nombor dlm vc[3] iaitu '5CYBERhiahia'
if not w.lower() == 'o': # biler kene w jadi C nanti dlm list y ade nombor jah
y.append(w)
else: # biler dah kene c maksud nya kiter dah ambek percentage voucher tu dalam kes ni bende tu 5% so dalam y ade ['5'] , kalau 12 nanti dlm y ade ['1', '2']
sotared[''.join(y)].append(vc) # kalu dlm y ade ['5'] nanti line ni membawa maksud sotared['5'].append(vc) lepastu [].append(vc) --> {'5':['5CYBERhiahia']}
break # pastu sambung kepade line seterus nya
f.close() # lepas habis susun semua voucher dalam vc, tutup file lame pastu bukak file baru untuk disusun untuk senang mata memandang mcm https://i.imgur.com/LztFyLz.png
f = open("vouncherSortedHi.txt", 'w') # dari sini, fhmlah kamu dengan sendirinya
for i in sotared:
f.write(i+"%"+" %i " % (len(sotared[i]))+"\n\n")
for magic in sotared[i]:
f.write(magic+"\n")
f.write("\n\n")
f.close()
print (time.ctime(int(time.time())))
print ("~====STATUS====~")
for key in sotared:
print (str(key)+": "+str(len(sotared[key])))
print ("~=END OF STATS=~")
time.sleep(1800)
while 1:
main()