Answer the question
In order to leave comments, you need to log in
How to explain to the bot that one of my things is already in the first place?
So. I hope I can find an answer here. I've been scratching my head for the 4th day, because. this is my first program.
I am making an inquiry about my items that are currently on sale. The answer comes. Example:
{'success': True, 'items': [{'item_id': '555268962', 'assetid': '0', 'classid': '310779105', 'instanceid': '0', 'real_instance': '302028390', 'market_hash_name': 'Desert Eagle | Mudder (Minimal Wear)', 'position': 6, 'price': 9, 'currency': 'RUB', 'status': '1', 'live_time': 1231, 'left': None, 'botid': '0'}, {'item_id': '555268959', 'assetid': '0', 'classid': '310779105', 'instanceid': '0', 'real_instance': '302028390', 'market_hash_name': 'Desert Eagle | Mudder (Minimal Wear)', 'position': 5, 'price': 9, 'currency': 'RUB', 'status': '1', 'live_time': 1231, 'left': None, 'botid': '0'}, {'item_id': '555268953', 'assetid': '0', 'classid': '310779105', 'instanceid': '0', 'real_instance': '302028390', 'market_hash_name': 'Desert Eagle | Mudder (Minimal Wear)', 'position': 4, 'price': 9, 'currency': 'RUB', 'status': '1', 'live_time': 1231, 'left': None, 'botid': '0'}, {'item_id': '555268947', 'assetid': '0', 'classid': '310779105', 'instanceid': '0', 'real_instance': '302028390', 'market_hash_name': 'Desert Eagle | Mudder (Minimal Wear)', 'position': 3, 'price': 9, 'currency': 'RUB', 'status': '1', 'live_time': 1232, 'left': None, 'botid': '0'}, {'item_id': '555268935', 'assetid': '0', 'classid': '310779105', 'instanceid': '0', 'real_instance': '302028390', 'market_hash_name': 'Desert Eagle | Mudder (Minimal Wear)', 'position': 2, 'price': 9, 'currency': 'RUB', 'status': '1', 'live_time': 1232, 'left': None, 'botid': '0'}]}
min_price = int(input())
i = 0
while True:
try:
item_req = 'https://market.csgo.com/api/v2/items?key=' + key
json_string = requests.get(item_req)
parsed_string = json.loads(json_string.text)
if parsed_string['items'][i]['position'] != 1:
search_item = 'https://market.csgo.com/api/v2/search-item-by-hash-name?key={0}&hash_name={1}'.format(key, name_item)
json_str = requests.get(search_item)
price_hash = json.loads(json_str.text)
print(datetime.now().strftime("%H:%M:%S"), price_hash)
price = price_hash['data'][i]['price']
print(datetime.now().strftime("%H:%M:%S"), 'Минимальная цена предмета {0} RUB'.format(price/100))
lowprice = price - 1
print(datetime.now().strftime("%H:%M:%S"), 'Ставлю цену {0} на {1}'.format(lowprice/100, name_item))
if lowprice >= min_price*100:
item_id = (parsed_string['items'][i]['item_id'])
set_price = 'https://market.csgo.com/api/v2/set-price?key={0}&item_id={1}&price={2}&cur=RUB'.format(key, item_id, lowprice)
response = requests.get(set_price)
setpr = json.loads(response.text)
if setpr['success'] == True:
print(datetime.now().strftime("%H:%M:%S"), 'Успешно')
time.sleep(10)
else:
print(datetime.now().strftime("%H:%M:%S"), 'Не могу понизить цену меньше минимальной')
else:
print(datetime.now().strftime("%H:%M:%S"), 'уже 1 позиция')
time.sleep(10)
i += 1
except IndexError:
pass
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question