Advertisement
Eazy_Peazy_Lemons

Untitled

Jan 7th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.66 KB | None | 0 0
  1. import requests
  2. import math
  3. import urllib
  4. import time
  5. from datetime import datetime
  6.  
  7.  
  8.  
  9. effect_dict={'6':'Green Confetti','7':'Purple Confetti','8':'Haunted Ghosts','9':'Green Energy','10':'Purple Energy','11':'Circling TF Logo','12':'Massed Flies','13':'Burning Flames','14':'Scorching Flames','17':'Sunbeams','29':'Stormy Storm','33':'Orbiting Fire','34':'Bubbling','35':'Smoking','36':'Steaming','38':'Cloudy Moon','56':'Kill-a-Watt','57':'Terror-Watt','58':'Cloud9','70':'Time Warp','15':'Searing Plasma','16':'Vivid Plasma','18':'Circling PeaceSign','19':'Circling Heart','30':'Blizzardy Storm','31':'Nutsn Bolts','32':'Orbiting Planets','37':'Flaming Lantern','39':'Cauldron Bubbles','40':'Eerie Orbiting Fire','43':'Knifestorm','44':'Misty Skull','45':'Harvest Moon','46':'Its A Secret To Everybody','47':'Stormy 13th Hour','59':'Aces High','60':'Dead Presidents','61':'Miami Nights','62':'Disco Beat Down','63':'Phosphorous','64':'Sulphurous','65':'Memory Leak','66':'Overclocked','67':'Electrostatic','68':'Power Surge','69':'Anti-Freeze','71':'Green Black Hole','72':'Roboactive','73':'Arcana','74':'Spellbound','75':'Chiroptera Venenata','76':'Poisoned Shadows','77':'Something Burning This Way Comes','78':'Hellfire','79':'Darkblaze','80':'Demonflame','3001':'Showstopper','3003':'Holy Grail','3004':'72','3005':'Fountain of Delight','3006':'Screaming Tiger','3007':'Skill Gotten Gains','3008':'Midnight Whirlwind','3009':'Silver Cyclone','3010':'Mega Strike','81':'Bonzo The All-Gnawing','82':'Amaranthine','83':'Stare From Beyond','84':'The Ooze','85':'Ghastly Ghosts Jr','86':'Haunted Phantasm Jr','3011':'Haunted Phantasm','3012':'Ghastly Ghosts','87':'Frostbite','88':'Molten Mallard','89':'Morning Glory','90':'Death at Dusk','91':'Abduction','92':'Atomic','93':'Subatomic','94':'Electric Hat Protector','95':'Magnetic Hat Protector','96':'Voltaic Hat Protector','97':'Galactic Codex','98':'Ancient Codex','99':'Nebula','100':'Death by Disco','101':'Its a mystery to everyone','102':'Its a puzzle to me','103':'Ether Trail','104':'Nether Trail','105':'Ancient Eldritch','106':'Eldritch Flame','701':'Weapon Effect','702':'Weapon Effect','703':'Weapon Effect','704':'Weapon Effect','107':'Neutron Star','108':'Tesla Coil','109':'Startstorm Slumber','110':'Starstorm Insomnia','3014':'Spectral Swirl','3015':'Infernal Flame','3013':'Hellish Inferno','3016':'Infernal Smoke'}
  10.  
  11. with open('steam_id.txt', 'r') as myfile:
  12. s = str(myfile.read().replace('\n', ''))
  13.  
  14. steam_id = s
  15.  
  16.  
  17.  
  18.  
  19. open('output.txt','w').close()
  20. with open('api_key.txt', 'r') as myfile:
  21. backpack_api_token = myfile.read().replace('\n', '')
  22. defindex_dict = eval(open('defindex_map.json').read())
  23.  
  24.  
  25.  
  26. def unusual_buyorder_scan():
  27. open('output.txt','a').write('UNUSUAL BUYORDERS'+'\n')
  28. curr_page = 1
  29. while True:
  30. payload = {'key':backpack_api_token,'item_names':1,'intent':'buy','fold':1,'page_size':'30','steamid':s,'quality':'5','page':curr_page}
  31. #print(payload)
  32. url = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload)
  33. r1 = requests.get(url)
  34. ret1 = r1.json()
  35.  
  36. for hats in ret1['buy']['listings']:
  37.  
  38. #print(defindex_dict[listing['item']])
  39.  
  40. if 'metal' not in hats['currencies'].keys():
  41. hats['currencies']['metal'] = 0;
  42. if 'keys' not in hats['currencies'].keys():
  43. hats['currencies']['keys'] = 0;
  44. my_keys = hats['currencies']['keys']
  45. my_metal = hats['currencies']['metal']
  46. curr_page1 = 1
  47. encoded_name = defindex_dict[hats['item']['defindex']]
  48.  
  49. while True:
  50.  
  51. if 'attributes' in hats['item'].keys():
  52. #print(hats['item']['name']+str(hats['item']['attributes'][0]['float_value']))
  53. payload1 = {'key':backpack_api_token,'item_names':1,'intent':'buy','fold':1,'page_size':'30','item':encoded_name,'quality':'5','particle':hats['item']['attributes'][0]['float_value'],'page':curr_page1}
  54.  
  55. else:
  56. #print(hats['item']['name'])
  57. payload1 = {'key':backpack_api_token,'item_names':1,'intent':'buy','fold':1,'page_size':'30','item':encoded_name,'quality':'5','page':curr_page1}
  58. iurl = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload1)
  59. ir1 = requests.get(iurl)
  60. iret1 = ir1.json()
  61.  
  62. for buyers in iret1['buy']['listings']:
  63.  
  64. if 'metal' not in buyers['currencies'].keys():
  65. buyers['currencies']['metal'] = 0
  66. if 'keys' not in buyers['currencies'].keys():
  67. buyers['currencies']['keys'] = 0
  68. buyers_keys = buyers['currencies']['keys']
  69. buyers_metal = buyers['currencies']['metal']
  70. buyers_name = buyers['steamid']
  71.  
  72.  
  73. if 'attributes' in hats['item'].keys():
  74. effect = effect_dict[str(hats['item']['attributes'][0]['float_value'])]
  75. else:
  76. effect = 'None'
  77. if 'attributes' in hats['item'].keys() and 'attributes' in buyers['item'].keys():
  78. if hats['item']['attributes'][0]['float_value'] == buyers['item']['attributes'][0]['float_value']:
  79. #print(buyers)
  80. if buyers_keys > my_keys or (buyers_keys == my_keys and buyers_metal > my_metal):
  81. output = '{:<45} {:<12} {:<12} {:<30} {:<12} {:<12}'.format(encoded_name+' '+effect, str(my_keys),str(my_metal),buyers_name,str(buyers_keys),str(buyers_metal))
  82. open('output.txt','a').write(output+'\n')
  83. print(output)
  84. elif 'attributes' not in hats['item'].keys() and 'attributes' not in buyers['item'].keys():
  85. if buyers_keys > my_keys or (buyers_keys == my_keys and buyers_metal > my_metal):
  86. #print(buyers)
  87. output = '{:<45} {:<12} {:<12} {:<30} {:<12} {:<12}'.format(encoded_name+' '+effect, str(my_keys),str(my_metal),buyers_name,str(buyers_keys),str(buyers_metal))
  88. print(output)
  89. open('output.txt','a').write(output+'\n')
  90.  
  91.  
  92. buyers_name = ''
  93. buyers_keys = ''
  94. buyers_metal = ''
  95. curr_page1 = curr_page1 + 1
  96. if curr_page1 > math.ceil(iret1['total'] / 30) or iret1['total'] < 31:
  97. break
  98.  
  99. curr_page = curr_page + 1
  100. if curr_page > math.ceil(ret1['total'] / 30) or ret1['total'] < 31:
  101. break
  102.  
  103. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : '+'UNUSUAL BUYORDER SEARCH COMPLETED')
  104.  
  105. def unusual_sellorder_scan():
  106. open('output.txt','a').write('UNUSUAL SELLORDERS'+'\n')
  107. curr_page = 1
  108. while True:
  109. payload = {'key':backpack_api_token,'item_names':1,'intent':'sell','fold':1,'page_size':'30','steamid':s,'quality':'5','page':curr_page}
  110. #print(payload)
  111. url = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload)
  112. r1 = requests.get(url)
  113. ret1 = r1.json()
  114.  
  115. for hats in ret1['sell']['listings']:
  116.  
  117. #print(defindex_dict[listing['item']])
  118.  
  119. if 'metal' not in hats['currencies'].keys():
  120. hats['currencies']['metal'] = 0;
  121. my_keys = hats['currencies']['keys']
  122. my_metal = hats['currencies']['metal']
  123. curr_page1 = 1
  124. encoded_name = defindex_dict[hats['item']['defindex']]
  125.  
  126. while True:
  127.  
  128. if 'attributes' in hats['item'].keys():
  129. #print(hats['item']['name']+str(hats['item']['attributes'][0]['float_value']))
  130. payload1 = {'key':backpack_api_token,'item_names':1,'intent':'sell','fold':1,'page_size':'30','item':encoded_name,'quality':'5','particle':hats['item']['attributes'][0]['float_value'],'page':curr_page1}
  131.  
  132. else:
  133. #print(hats['item']['name'])
  134. payload1 = {'key':backpack_api_token,'item_names':1,'intent':'sell','fold':1,'page_size':'30','item':encoded_name,'quality':'5','page':curr_page1}
  135. iurl = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload1)
  136. ir1 = requests.get(iurl)
  137. iret1 = ir1.json()
  138.  
  139. for buyers in iret1['sell']['listings']:
  140.  
  141. if 'metal' not in buyers['currencies'].keys():
  142. buyers['currencies']['metal'] = 0
  143. if 'keys' not in buyers['currencies'].keys():
  144. buyers['currencies']['keys'] = 0
  145. buyers_keys = buyers['currencies']['keys']
  146. buyers_metal = buyers['currencies']['metal']
  147. buyers_name = buyers['steamid']
  148.  
  149.  
  150. if 'attributes' in hats['item'].keys():
  151. effect = effect_dict[str(hats['item']['attributes'][0]['float_value'])]
  152. else:
  153. effect = 'None'
  154. if 'attributes' in hats['item'].keys() and 'attributes' in buyers['item'].keys():
  155. if hats['item']['attributes'][0]['float_value'] == buyers['item']['attributes'][0]['float_value']:
  156. #print(buyers)
  157. if buyers_keys < my_keys or (buyers_keys == my_keys and buyers_metal < my_metal):
  158. output = '{:<45} {:<12} {:<12} {:<30} {:<12} {:<12}'.format(encoded_name+' '+effect, str(my_keys),str(my_metal),buyers_name,str(buyers_keys),str(buyers_metal))
  159. open('output.txt','a').write(output+'\n')
  160. print(output)
  161. elif 'attributes' not in hats['item'].keys() and 'attributes' not in buyers['item'].keys():
  162. if buyers_keys < my_keys or (buyers_keys == my_keys and buyers_metal < my_metal):
  163. #print(buyers)
  164. output = '{:<45} {:<12} {:<12} {:<30} {:<12} {:<12}'.format(encoded_name+' '+effect, str(my_keys),str(my_metal),buyers_name,str(buyers_keys),str(buyers_metal))
  165. print(output)
  166. open('output.txt','a').write(output+'\n')
  167.  
  168.  
  169. buyers_name = ''
  170. buyers_keys = ''
  171. buyers_metal = ''
  172. curr_page1 = curr_page1 + 1
  173. if curr_page1 > math.ceil(iret1['total'] / 30) or iret1['total'] < 31:
  174. break
  175.  
  176. curr_page = curr_page + 1
  177. if curr_page > math.ceil(ret1['total'] / 30) or ret1['total'] < 31:
  178. break
  179.  
  180. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : '+ 'UNUSUAL SELLORDER SEARCH COMPLETED')
  181.  
  182.  
  183. def get_buyorders(item_name,item_quality,item_keys,item_metal,item_killstreaker,item_listing_offers,item_listing_buyout,item_listing_message,item_listing_id,item_encoded_name,item_defindex):
  184. curr_page1 = 1
  185. my_keys = item_keys
  186. my_metal = item_metal
  187. buyers_list = []
  188.  
  189. while True:
  190.  
  191. payload1 = {'key':backpack_api_token,'item_names':1,'intent':'buy','fold':1,'page_size':'30','item':item_encoded_name,'quality':item_quality,'killstreak_tier':item_killstreaker,'page':curr_page1}
  192.  
  193. iurl = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload1)
  194. ir1 = requests.get(iurl)
  195. iret1 = ir1.json()
  196. #print(iret1)
  197. if curr_page1 > 1:
  198. time.sleep(2)
  199.  
  200. if 'response' in iret1.keys() and 'success' in iret1['response'].keys() and str(iret1['response']['success']) == '0':
  201. time.sleep(5)
  202. get_buyorders(item_name,item_quality,item_keys,item_metal,item_killstreaker,item_listing_offers,item_listing_buyout,item_listing_message,item_listing_id,item_encoded_name,item_defindex)
  203. return
  204. else:
  205. for buyers in iret1['buy']['listings']:
  206. if 'metal' not in buyers['currencies'].keys():
  207. buyers['currencies']['metal'] = 0
  208. if 'keys' not in buyers['currencies'].keys():
  209. buyers['currencies']['keys'] = 0
  210. buyers_keys = buyers['currencies']['keys']
  211. buyers_metal = buyers['currencies']['metal']
  212. buyers_name = buyers['steamid']
  213.  
  214. if buyers_name != steam_id and buyers['item']['name'] == item_name:
  215. if (buyers_keys < my_keys or (buyers_keys == my_keys and buyers_metal < my_metal)):
  216. output = '{:<45} {:<12} {:<12} {:<30} {:<12} {:<12}'.format(item_name, str(my_keys),str(my_metal),buyers_name,str(buyers_keys),str(buyers_metal))
  217. print(output)
  218. open('output.txt','a').write(output+'\n')
  219.  
  220.  
  221. buyers_name = ''
  222. buyers_keys = ''
  223. buyers_metal = ''
  224. curr_page1 = curr_page1 + 1
  225. if curr_page1 > math.ceil(iret1['total'] / 30) or iret1['total'] < 31:
  226. break
  227.  
  228. def buyorder_scan():
  229. open('output.txt','a').write('OTHER BUYORDERS'+'\n')
  230. curr_page = 1
  231. while True:
  232. payload = {'key':backpack_api_token,'item_names':1,'intent':'buy','fold':1,'page_size':'30','steamid':s,'page':curr_page}
  233. #print(payload)
  234. url = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload)
  235. r1 = requests.get(url)
  236. ret1 = r1.json()
  237. #print(ret1)
  238. for item in ret1['buy']['listings']:
  239. if str(item['item']['quality']) != str(5) and item['item']['defindex'] in defindex_dict.keys():
  240. if 'metal' not in item['currencies'].keys():
  241. item['currencies']['metal'] = 0;
  242. if 'keys' not in item['currencies'].keys():
  243. item['currencies']['keys'] = 0
  244. item_keys = item['currencies']['keys']
  245. item_metal = item['currencies']['metal']
  246. item_name = item['item']['name']
  247. item_defindex = item['item']['defindex']
  248. item_encoded_name = defindex_dict[item['item']['defindex']]
  249. item_quality = item['item']['quality']
  250. item_killstreaker = 0
  251. if 'attributes' in item['item'].keys():
  252. for stuff in item['item']['attributes']:
  253. if stuff['defindex'] == 2025:
  254. item_killstreaker = stuff['float_value']
  255. item_listing_id = item['id']
  256. item_listing_message = item['details']
  257. item_listing_offers = item['offers']
  258. item_listing_buyout = item['buyout']
  259. #print(item)
  260. get_buyorders(item_name,item_quality,item_keys,item_metal,item_killstreaker,item_listing_offers,item_listing_buyout,item_listing_message,item_listing_id,item_encoded_name,item_defindex)
  261.  
  262.  
  263. curr_page = curr_page + 1
  264. if curr_page > math.ceil(ret1['total'] / 30) or ret1['total'] < 31:
  265. break
  266.  
  267. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : '+ 'OTHER BUYORDERS SEARCH COMPLETED')
  268.  
  269.  
  270. def get_sellorders(item_name,item_id,item_quality,item_keys,item_metal,item_killstreaker,item_listing_offers,item_listing_buyout,item_listing_message,item_listing_id,item_encoded_name):
  271. curr_page1 = 1
  272. my_keys = item_keys
  273. my_metal = item_metal
  274. sellers_list = []
  275.  
  276. while True:
  277.  
  278. payload1 = {'key':backpack_api_token,'item_names':1,'intent':'sell','fold':1,'page_size':'30','item':item_encoded_name,'quality':item_quality,'killstreak_tier':item_killstreaker,'page':curr_page1}
  279.  
  280. iurl = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload1)
  281. ir1 = requests.get(iurl)
  282. iret1 = ir1.json()
  283. #print(iret1)
  284. if curr_page1 > 1:
  285. time.sleep(2)
  286. #print(iret1.keys(),iret1['response'].keys(),iret1['response']['success'])
  287. if 'response' in iret1.keys() and 'success' in iret1['response'].keys() and str(iret1['response']['success']) == '0' and 'This interface has a cooldown of 5 seconds per key.' in iret1['response']['message']:
  288. time.sleep(5)
  289. get_sellorders(item_name,item_id,item_quality,item_keys,item_metal,item_killstreaker,item_listing_offers,item_listing_buyout,item_listing_message,item_listing_id,item_encoded_name)
  290. return
  291. else:
  292.  
  293. for sellers in iret1['sell']['listings']:
  294. if 'metal' not in sellers['currencies'].keys():
  295. sellers['currencies']['metal'] = 0
  296. if 'keys' not in sellers['currencies'].keys():
  297. sellers['currencies']['keys'] = 0
  298. sellers_keys = sellers['currencies']['keys']
  299. sellers_metal = sellers['currencies']['metal']
  300. sellers_name = sellers['steamid']
  301.  
  302. if sellers_name != steam_id and item_name == sellers['item']['name']:
  303. if (sellers_keys < my_keys or (sellers_keys == my_keys and sellers_metal < my_metal)):
  304. output = '{:<45} {:<12} {:<12} {:<30} {:<12} {:<12}'.format(item_name, str(my_keys),str(my_metal),sellers_name,str(sellers_keys),str(sellers_metal))
  305. print(output)
  306. open('output.txt','a').write(output+'\n')
  307.  
  308.  
  309. sellers_name = ''
  310. sellers_keys = ''
  311. sellers_metal = ''
  312. curr_page1 = curr_page1 + 1
  313. if curr_page1 > math.ceil(iret1['total'] / 30) or iret1['total'] < 31:
  314. break
  315.  
  316.  
  317. def sellorder_scan():
  318. open('output.txt','a').write('OTHER SELLORDERS'+'\n')
  319. curr_page = 1
  320. while True:
  321. payload = {'key':backpack_api_token,'item_names':1,'intent':'sell','fold':1,'page_size':'30','steamid':s,'page':curr_page}
  322. #print(payload)
  323. url = 'https://backpack.tf/api/classifieds/search/v1?' + urllib.parse.urlencode(payload)
  324. r1 = requests.get(url)
  325. ret1 = r1.json()
  326. #print(ret1)
  327. for item in ret1['sell']['listings']:
  328. if str(item['item']['quality']) != str(5) and item['item']['defindex'] in defindex_dict.keys():
  329. if 'metal' not in item['currencies'].keys():
  330. item['currencies']['metal'] = 0;
  331. if 'keys' not in item['currencies'].keys():
  332. item['currencies']['keys'] = 0
  333. item_id = item['item']['id']
  334. item_keys = item['currencies']['keys']
  335. item_metal = item['currencies']['metal']
  336. item_name = item['item']['name']
  337. item_encoded_name = defindex_dict[item['item']['defindex']]
  338. item_quality = item['item']['quality']
  339. item_killstreaker = 0
  340. if 'attributes' in item['item'].keys():
  341. for stuff in item['item']['attributes']:
  342. if stuff['defindex'] == 2025:
  343. item_killstreaker = stuff['float_value']
  344. item_listing_id = item['id']
  345. item_listing_message = item['details']
  346. item_listing_offers = item['offers']
  347. item_listing_buyout = item['buyout']
  348. #print(item)
  349.  
  350. get_sellorders(item_name,item_id,item_quality,item_keys,item_metal,item_killstreaker,item_listing_offers,item_listing_buyout,item_listing_message,item_listing_id,item_encoded_name)
  351.  
  352. curr_page = curr_page + 1
  353. if curr_page > math.ceil(ret1['total'] / 30) or ret1['total'] < 31:
  354. break
  355.  
  356. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : '+ 'OTHER SELLORDERS SEARCH COMPLETED')
  357.  
  358.  
  359. def main():
  360. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : '+'Scan Starting...')
  361. unusual_buyorder_scan()
  362. unusual_sellorder_scan()
  363. buyorder_scan()
  364. sellorder_scan()
  365. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : ALL SCANS COMPLETED')
  366. print(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))+ ' : Safe to Exit...')
  367.  
  368. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement