Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import datetime
- import time
- import threading
- from queue import Queue
- secret_key = '48R4q5Zzd7459FgPKGKYQje92RdjtH6'
- datas = list()
- datas_backup = list()
- countIter = 0
- def setPrice(secret_key, item_id, price):
- try:
- URL = 'https://market.csgo.com/api/v2/set-price?key=' + secret_key + '&item_id=' + str(
- item_id) + '&price=' + str(price * 100) + '&cur=RUB'
- resp = requests.get(URL).json()
- except json.decoder.JSONDecodeError:
- print(getOutPutTime(), 'JSON не найден! Проверьте корректность данных')
- def getOutPutTime():
- return datetime.datetime.now().strftime('[%H:%M:%S] ')
- def Main():
- URL = 'https://market.csgo.com/api/v2/update-inventory/?key=' + secret_key
- resp = requests.get(URL)
- Seller(secret_key)
- def Seller(secret_key):
- try:
- try:
- try:
- global datas
- global countIter
- global datas_backup
- ixsa = 0
- URL = 'https://market.csgo.com/api/v2/my-inventory/?key=48R4q5Zzd7459FgPKGKYQje92RdjtH6'
- response = requests.get(URL)
- for x in response.json()['items']:
- # Тут кол-во предметов ставить)))
- if ixsa < 1:
- ITEM_URL = 'https://market.csgo.com/api/v2/search-item-by-hash-name?key=48R4q5Zzd7459FgPKGKYQje92RdjtH6&hash_name=' + \
- x['market_hash_name']
- item_response = requests.get(ITEM_URL)
- price = 0.00;
- for y in item_response.json()['data']:
- price = float(y['price'] - 2) / 100
- break
- print(getOutPutTime(),
- 'Продаю предмет: ' + x['market_hash_name'] + ' за - ' + str(price) + 'RUB')
- SellItemByID(x['id'], price, 'RUB')
- data = x['market_hash_name'] + ":" + x['id']
- datas.append(data)
- datas_backup.append(data)
- time.sleep(0.33)
- ixsa += 1
- countIter = ixsa
- except json.decoder.JSONDecodeError:
- print(getOutPutTime(), 'JSON не найден! Вещи на продажу не найдены или уже были распроданы!')
- except ConnectionResetError:
- print(getOutPutTime(), 'Соединение с сервером прервано! Проверьте подключение к интернету!')
- except NameError:
- print(getOutPutTime(), 'Вещи на продажу не найдены или уже были распроданы!')
- CheckPrice(secret_key)
- def CheckPrice(secret_key):
- try:
- try:
- try:
- global countIter
- countIterations = 0
- newcountiter = countIter
- while True:
- item_name = ''
- item_id = 0
- id = 0
- price = 0.00
- global datas
- global datas_backup
- if countIterations == newcountiter:
- print(getOutPutTime(), 'Запускаю новый цикл!')
- datas = datas_backup.copy()
- newcountiter += countIter
- for c in datas:
- c = c.split(':')
- item_name = c[0]
- item_id = c[1]
- datas.pop(0)
- break
- imbanana = False
- if isSelled(secret_key, item_name) == True:
- print(getOutPutTime(), 'Предмет был продан!')
- continue
- try:
- URL = 'https://market.csgo.com/api/v2/search-item-by-hash-name-specific?key=' + secret_key + '&hash_name=' + item_name
- resp = requests.get(URL).json()["data"]
- except:
- resp = {'response': False}
- imbanana = True
- if imbanana == True:
- continue
- for i in resp:
- price = i['price']
- id = i['id']
- break
- price = float(price / 100)
- if int(id) != int(item_id):
- print(getOutPutTime(), 'Найден другой ТОП-1 предмет! Сбиваю цену!')
- print(getOutPutTime(), 'Цена с ' + str(price) + ' сбита до ' + str(price - 0.02))
- setPrice(secret_key, id, (price - 0.02))
- else:
- print(getOutPutTime(), 'Ваш предмет:' + item_name + ' всё еще ТОП-1')
- countIterations += 1
- # Тут задержку ставить
- time.sleep(1)
- except KeyError:
- print(getOutPutTime(), 'Ошибка в поиске предмета! ну тут ряльна жопа')
- CheckPrice(secret_key)
- except NameError:
- print(getOutPutTime(), 'Ошибка в парсинге JSON')
- except json.decoder.JSONDecodeError:
- print(getOutPutTime(), 'Ошибка JSON')
- CheckPrice(secret_key)
- def isSelled(secret_key, name):
- try:
- URL = 'https://market.csgo.com/api/v2/items?key=' + secret_key
- response = requests.get(URL).json['items']
- for i in response:
- item_status = i[i]['status']
- item_hash_name = i[i]['market_hash_name']
- if status == 2 and item_hash_name == name:
- return True
- else:
- return False
- except:
- return False
- print(getOutPutTime(), 'Ошибка JSON')
- def SellItemByID(item_id, price, cur):
- price = price * 100
- URL = 'https://market.csgo.com/api/v2/add-to-sale?key=48R4q5Zzd7459FgPKGKYQje92RdjtH6&id=' + item_id + '&price=' + str(
- price) + '&cur=' + cur
- response = requests.get(URL).json()
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement