код:
def add():
r = requests.get('https://market.csgo.com/api/v2/update-inventory/?key=x')
time.sleep(20)
checkitems = requests.get('https://market.csgo.com/api/v2/my-inventory/?key=x')
if checkitems.status_code == 200:
k = len(checkitems.json()['items'])
for x in range(k):
itemid = checkitems.json()['items'][x]['id']
itemid2 = str(itemid)
time.sleep(2)
r = requests.get('https://market.csgo.com/api/v2/add-to-sale?key=3x&id=' + itemid2 + '&price=9999999&cur=RUB')
time.sleep(200)
add()
t = threading.Thread(target=add)
t.start()
def func():
xclass = []
moment = []
while True:
time.sleep(1)
result = requests.get('https://market.csgo.com/api/v2/items?key=3F5TxNL')
if result.status_code == 200:
if result.json()['success'] == True:
if result.json()['items'] != None:
m = len(result.json()['items'])
for o in range(m):
classid = result.json()['items'][o]['classid']
xclass.append(classid)
for x in range(m):
myprice = result.json()['items'][x]['price']
itemid = result.json()['items'][x]['item_id']
hashname = result.json()['items'][x]['market_hash_name']
rewss = requests.get('https://market.csgo.com/api/v2/search-item-by-hash-name?key=xL&hash_name=' + hashname)
if rewss.status_code == 200:
if rewss.json()['success'] == True:
if result.json()['items'][x]['position'] != 0:
if rewss.json()['data'] != []:
k = len(rewss.json()['data'])
if k > 1:
for j in range(k):
firstprice = rewss.json()['data'][0]['price']
nowa = float(firstprice) / 100
if myprice != nowa:
cla = rewss.json()['data'][0]['class']
newprais = float(firstprice) - 1.0
if hashname == rewss.json()['data'][j]['market_hash_name']:
duplicates = [int(k) for k, v in Counter(xclass).items() if v > 1]
if cla not in duplicates:
newprice1 = str(newprais)
currency = result.json()['items'][x]['currency']
time.sleep(1)
r = requests.get('https://market.csgo.com/api/v2/set-price?key=3xL&item_id=' + itemid + '&price=' + newprice1 + '&cur=' + currency + '&')
func()
func()
Есть какой либо вариант справиться с этой проблемой не убирая рекурсию? Или как-то иначе?