Advertisement
P3rth0

Untitled

Feb 4th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. import requests
  2. import json
  3. import datetime
  4. import time
  5. import threading
  6. from queue import Queue
  7.  
  8. secret_key = '48R4q5Zzd7459FgPKGKYQje92RdjtH6'
  9.  
  10. datas = list()
  11. datas_backup = list()
  12.  
  13. countIter = 0
  14.  
  15.  
  16. def setPrice(secret_key, item_id, price):
  17. try:
  18. URL = 'https://market.csgo.com/api/v2/set-price?key=' + secret_key + '&item_id=' + str(
  19. item_id) + '&price=' + str(price * 100) + '&cur=RUB'
  20. resp = requests.get(URL).json()
  21.  
  22. except json.decoder.JSONDecodeError:
  23. print(getOutPutTime(), 'JSON не найден! Проверьте корректность данных')
  24.  
  25.  
  26. def getOutPutTime():
  27. return datetime.datetime.now().strftime('[%H:%M:%S] ')
  28.  
  29.  
  30. def Main():
  31. URL = 'https://market.csgo.com/api/v2/update-inventory/?key=' + secret_key
  32. resp = requests.get(URL)
  33. Seller(secret_key)
  34.  
  35.  
  36. def Seller(secret_key):
  37. try:
  38. try:
  39. try:
  40. global datas
  41. global countIter
  42. global datas_backup
  43. ixsa = 0
  44. URL = 'https://market.csgo.com/api/v2/my-inventory/?key=48R4q5Zzd7459FgPKGKYQje92RdjtH6'
  45. response = requests.get(URL)
  46. for x in response.json()['items']:
  47. # Тут кол-во предметов ставить)))
  48. if ixsa < 1:
  49. ITEM_URL = 'https://market.csgo.com/api/v2/search-item-by-hash-name?key=48R4q5Zzd7459FgPKGKYQje92RdjtH6&hash_name=' + \
  50. x['market_hash_name']
  51. item_response = requests.get(ITEM_URL)
  52. price = 0.00;
  53. for y in item_response.json()['data']:
  54. price = float(y['price'] - 2) / 100
  55. break
  56. print(getOutPutTime(),
  57. 'Продаю предмет: ' + x['market_hash_name'] + ' за - ' + str(price) + 'RUB')
  58. SellItemByID(x['id'], price, 'RUB')
  59. data = x['market_hash_name'] + ":" + x['id']
  60. datas.append(data)
  61. datas_backup.append(data)
  62. time.sleep(0.33)
  63. ixsa += 1
  64. countIter = ixsa
  65. except json.decoder.JSONDecodeError:
  66. print(getOutPutTime(), 'JSON не найден! Вещи на продажу не найдены или уже были распроданы!')
  67. except ConnectionResetError:
  68. print(getOutPutTime(), 'Соединение с сервером прервано! Проверьте подключение к интернету!')
  69. except NameError:
  70. print(getOutPutTime(), 'Вещи на продажу не найдены или уже были распроданы!')
  71.  
  72. CheckPrice(secret_key)
  73.  
  74.  
  75. def CheckPrice(secret_key):
  76. try:
  77. try:
  78. try:
  79. global countIter
  80. countIterations = 0
  81. newcountiter = countIter
  82. while True:
  83. item_name = ''
  84. item_id = 0
  85. id = 0
  86. price = 0.00
  87. global datas
  88. global datas_backup
  89. if countIterations == newcountiter:
  90. print(getOutPutTime(), 'Запускаю новый цикл!')
  91. datas = datas_backup.copy()
  92. newcountiter += countIter
  93. for c in datas:
  94. c = c.split(':')
  95. item_name = c[0]
  96. item_id = c[1]
  97. datas.pop(0)
  98. break
  99. imbanana = False
  100. if isSelled(secret_key, item_name) == True:
  101. print(getOutPutTime(), 'Предмет был продан!')
  102. continue
  103. try:
  104. URL = 'https://market.csgo.com/api/v2/search-item-by-hash-name-specific?key=' + secret_key + '&hash_name=' + item_name
  105. resp = requests.get(URL).json()["data"]
  106. except:
  107. resp = {'response': False}
  108. imbanana = True
  109. if imbanana == True:
  110. continue
  111. for i in resp:
  112. price = i['price']
  113. id = i['id']
  114. break
  115. price = float(price / 100)
  116. if int(id) != int(item_id):
  117. print(getOutPutTime(), 'Найден другой ТОП-1 предмет! Сбиваю цену!')
  118. print(getOutPutTime(), 'Цена с ' + str(price) + ' сбита до ' + str(price - 0.02))
  119. setPrice(secret_key, id, (price - 0.02))
  120. else:
  121. print(getOutPutTime(), 'Ваш предмет:' + item_name + ' всё еще ТОП-1')
  122. countIterations += 1
  123. # Тут задержку ставить
  124. time.sleep(1)
  125. except KeyError:
  126. print(getOutPutTime(), 'Ошибка в поиске предмета! ну тут ряльна жопа')
  127. CheckPrice(secret_key)
  128. except NameError:
  129. print(getOutPutTime(), 'Ошибка в парсинге JSON')
  130. except json.decoder.JSONDecodeError:
  131. print(getOutPutTime(), 'Ошибка JSON')
  132. CheckPrice(secret_key)
  133.  
  134.  
  135. def isSelled(secret_key, name):
  136. try:
  137. URL = 'https://market.csgo.com/api/v2/items?key=' + secret_key
  138. response = requests.get(URL).json['items']
  139. for i in response:
  140. item_status = i[i]['status']
  141. item_hash_name = i[i]['market_hash_name']
  142. if status == 2 and item_hash_name == name:
  143. return True
  144. else:
  145. return False
  146. except:
  147. return False
  148. print(getOutPutTime(), 'Ошибка JSON')
  149.  
  150.  
  151. def SellItemByID(item_id, price, cur):
  152. price = price * 100
  153. URL = 'https://market.csgo.com/api/v2/add-to-sale?key=48R4q5Zzd7459FgPKGKYQje92RdjtH6&id=' + item_id + '&price=' + str(
  154. price) + '&cur=' + cur
  155. response = requests.get(URL).json()
  156.  
  157.  
  158. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement