Advertisement
Guest User

Untitled

a guest
May 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. import requests, json, time, dhooks
  2. from dhooks import Webhook, Embed
  3. products = []
  4. prices = []
  5. images = []
  6. new_item_index = []
  7. new_prices = []
  8. lengths = []
  9. prod = None
  10. price = None
  11. image = None
  12. new = None
  13. index = 0
  14.  
  15. hook = Webhook('https://discordapp.com/api/webhooks/579422749563289611/Vi60bdgMCzB1QdjA4se8W3PJMNvEQDAzBnQgktkfsGoN9wi7DqXQOtuNjdnwCE_wAS_g')
  16. url = 'https://www.supremenewyork.com/mobile_stock.json'
  17. r = requests.get(url).json()['products_and_categories']
  18. categories = ['Accessories', 'Pants', 'Sweatshirts', 'Bags', 'Tops/Sweaters', 'Shorts', 'Shirts', 'Hats', 'Jackets', 'Skate', 'new']
  19. options = '''
  20. 1. Accessories
  21. 2. Pants
  22. 3. Sweatshirts
  23. 4. Bags
  24. 5. Tops/Sweaters
  25. 6. Shorts
  26. 7. Shirts
  27. 8. Hats
  28. 9. Jackets
  29. 10. Skate
  30. '''
  31. choice = input("Do you want to find out the information about every product in a specific category? (information) or the number of products in all categories? (number)")
  32. if choice == "information":
  33. while True:
  34. try:
  35. number = int(input(options + '\n Type the number for the category you want: '))
  36. except ValueError:
  37. print("Sorry, I didn't understand that.")
  38. continue
  39. if number < 1 or number > 10:
  40. print("Sorry, this is not a valid response.")
  41. continue
  42. else:
  43. break
  44. category = categories[number-1]
  45. print(category)
  46.  
  47. for p in r[category]:
  48. print("Product: {}".format(p['name']))
  49. products.append(p['name'])
  50. print("Price: {}".format(p['price']))
  51. prices.append('$' + str(p['price']))
  52. print("Image URL: {}".format(p['image_url_hi']))
  53. images.append("https:" + p['image_url_hi'])
  54. print("New Item? {}".format(p['new_item']))
  55. new_item_index.append(p['new_item'])
  56. print("------------------------------")
  57.  
  58. for p in prices:
  59. new_prices.append(p[:-2] + '.' + p[-2:])
  60.  
  61. for i in range(0,len(products)):
  62. prod = products[index]
  63. price = new_prices[index]
  64. image = images[index]
  65. new = new_item_index[index]
  66. embed = Embed(
  67. description='Supreme Product Scraper',
  68. color=24576,
  69. timestamp='now'
  70. )
  71. embed.set_author(name='Monitor')
  72. embed.add_field(name='Product', value=prod)
  73. embed.add_field(name='Price', value=price)
  74. embed.add_field(name='New product?', value=new)
  75. embed.set_footer(text='Supreme Scraper by @Hunterkicks')
  76. hook.send(embed=embed)
  77. index += 1
  78. else:
  79. for p in r['Accessories']:
  80. products.append(p['name'])
  81. answer = ("The number of products in Accessories is " + str(len(products)))
  82. embed = Embed(
  83. description='Supreme Product Counter',
  84. color=24576,
  85. timestamp='now'
  86. )
  87. embed.set_author(name='Product counter')
  88. embed.add_field(name='----------', value=answer)
  89. hook.send(embed=embed)
  90. products.clear()
  91.  
  92. for p in r['Pants']:
  93. products.append(p['name'])
  94. answer = ("The number of products in Pants is " + str(len(products)))
  95. embed = Embed(
  96. description='Supreme Product Counter',
  97. color=24576,
  98. timestamp='now'
  99. )
  100. embed.set_author(name='Product counter')
  101. embed.add_field(name='----------', value=answer)
  102. hook.send(embed=embed)
  103. products.clear()
  104.  
  105. for p in r['Sweatshirts']:
  106. products.append(p['name'])
  107. answer = ("The number of products in Sweatshirts is " + str(len(products)))
  108. embed = Embed(
  109. description='Supreme Product Counter',
  110. color=24576,
  111. timestamp='now'
  112. )
  113. embed.set_author(name='Product counter')
  114. embed.add_field(name='----------', value=answer)
  115. hook.send(embed=embed)
  116. products.clear()
  117.  
  118. for p in r['Tops/Sweaters']:
  119. products.append(p['name'])
  120. answer = ("The number of products in Tops/Sweaters is " + str(len(products)))
  121. embed = Embed(
  122. description='Supreme Product Counter',
  123. color=24576,
  124. timestamp='now'
  125. )
  126. embed.set_author(name='Product counter')
  127. embed.add_field(name='----------', value=answer)
  128. hook.send(embed=embed)
  129. products.clear()
  130.  
  131. for p in r['Shorts']:
  132. products.append(p['name'])
  133. answer = ("The number of products in Shorts is " + str(len(products)))
  134. embed = Embed(
  135. description='Supreme Product Counter',
  136. color=24576,
  137. timestamp='now'
  138. )
  139. embed.set_author(name='Product counter')
  140. embed.add_field(name='----------', value=answer)
  141. hook.send(embed=embed)
  142. products.clear()
  143.  
  144. for p in r['Shirts']:
  145. products.append(p['name'])
  146. answer = ("The number of products in Shirts is " + str(len(products)))
  147. embed = Embed(
  148. description='Supreme Product Counter',
  149. color=24576,
  150. timestamp='now'
  151. )
  152. embed.set_author(name='Product counter')
  153. embed.add_field(name='----------', value=answer)
  154. hook.send(embed=embed)
  155. products.clear()
  156.  
  157. for p in r['Hats']:
  158. products.append(p['name'])
  159. answer = ("The number of products in Hats is " + str(len(products)))
  160. embed = Embed(
  161. description='Supreme Product Counter',
  162. color=24576,
  163. timestamp='now'
  164. )
  165. embed.set_author(name='Product counter')
  166. embed.add_field(name='----------', value=answer)
  167. hook.send(embed=embed)
  168. products.clear()
  169.  
  170. for p in r['Jackets']:
  171. products.append(p['name'])
  172. answer = ("The number of products in Jackets is " + str(len(products)))
  173. embed = Embed(
  174. description='Supreme Product Counter',
  175. color=24576,
  176. timestamp='now'
  177. )
  178. embed.set_author(name='Product counter')
  179. embed.add_field(name='----------', value=answer)
  180. hook.send(embed=embed)
  181. products.clear()
  182.  
  183. for p in r['Skate']:
  184. products.append(p['name'])
  185. asnwer = ("The number of products in Skate is " + str(len(products)))
  186. embed = Embed(
  187. description='Supreme Product Counter',
  188. color=24576,
  189. timestamp='now'
  190. )
  191. embed.set_author(name='Product counter')
  192. embed.add_field(name='----------', value=answer)
  193. hook.send(embed=embed)
  194. products.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement