1

код:

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

Есть какой либо вариант справиться с этой проблемой не убирая рекурсию? Или как-то иначе?

2
  • ``` import sys sys.setrecursionlimit(10**6) ```
    – Serhii
    26 окт 2019 в 18:06
  • Так программа работает часа 4
    – artemso72
    10 ноя 2019 в 11:45

1 ответ 1

2

Нет, нельзя. В Вашем коде нет логики возврата из рекурсивных вызовов (если запросы возвращаются со статусом 200). Замените рекурсию на цикл.

1
  • Не подскажите как?
    – artemso72
    30 окт 2019 в 13:42

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.