Загрузка...

Change the structure of a function

Thread in Python created by daybnsad Sep 28, 2019. 141 view

  1. daybnsad
    daybnsad Topic starter Sep 28, 2019 Banned 19 Oct 2, 2018
    Попытался объяснить как можно подробнее)
    есть функция:
    Code
    def func():
    xclass = []
    while True:
    result = requests.get('https://market.csgo.com/api/v2/items?key=xxxxxxxxxxxxxxxxxxxx').json()
    if result['success'] == True:
    if result['items'] != 'null':
    m = len(result['items'])
    for o in range(m):
    classid = result['items'][o]['classid']
    xclass.append(classid)
    for x in range(m):
    itemid = result['items'][x]['item_id']
    hashname = result['items'][x]['market_hash_name']
    rewss = requests.get('https://market.csgo.com/api/v2/search-item-by-hash-name?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxx&hash_name=' + hashname).json()
    if result['items'][x]['position'] != 1:
    if result['items'][x]['position'] != 0:
    if rewss['data'] != []:
    k = len(rewss['data'])
    for j in range(k):
    firstprice = min(rewss['data'], key=lambda x: x['price'])['price']
    cla = min(rewss['data'], key=lambda x: x['price'])['class']
    newprais = float(firstprice) - 1.0
    if hashname == rewss['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['items'][x]['currency']
    r = requests.get('https://market.csgo.com/api/v2/set-price?key=xxxxxxxxxxxxxxxxxxxxx&item_id=' + itemid + '&price=' + newprice1 + '&cur=' + currency + '&')
    func()
    func()
    Скрипт анализирует цены и если моя позиция цены не равна 0 или 1 - меняет ее на цену,которая ниже минимальной на копейку.Проблема в том,что после последнего реквеста скрипт стартует заново.я пробовал убирать рекурсию(func()) тогда он застывает в последнем цикле.Я хочу чтобы он сначала проанализировал,потом менял и проанализированные элементы отсекал,а потом начинал все заново.Помагити
     
  2. oriole
    oriole Sep 28, 2019 был(а) давно
    может вызов функции добавить в цикл while True ? хз поможет ли
     
  3. Kyber_Zero
    Kyber_Zero Sep 28, 2019 Dead Inside 5 Jan 21, 2018
    Ой бляяя........:roflanFacepalm::press_f:
     
Loading...
Top