Advertisement
Guest User

kickz monitor

a guest
Oct 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. ##############################
  2. # KICKZ MONITOR BY LULABA#7436
  3. ##############################
  4.  
  5. from bs4 import BeautifulSoup
  6. from datetime import datetime
  7. import requests
  8. import time
  9. import json
  10. from proxymanager import ProxyManager
  11. from dhooks import Webhook, Embed
  12. from tinydb import TinyDB, Query
  13. from colorama import init
  14. init()
  15. ##################
  16.  
  17. db = TinyDB('db.json')
  18. hook = Webhook('https://discordapp.com/api/webhooks/633385841011458079/buCdFclVoe02gVgTODUYqX-E221px3_mBULsic7k45iW6c6A0zzqdrZMdcHSt_7iJxY5', username = 'https://www.kickz.com', avatar_url = 'https://pbs.twimg.com/profile_images/592962053737951232/GOK0vBH5_400x400.jpg')
  19. mainUrl = 'https://www.kickz.com/it/jordan-basket-retro-air-jordan-1-retro-high-og-black_gym_red_white_sail-107840042'
  20. proxylist = ProxyManager('proxies.txt')
  21. headers = {'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Mobile Safari/537.36',
  22. 'upgrade-insecure-requests':'1',
  23. 'cache-control':'max-age=0',
  24. 'accept-language':'it-IT,it;q=0.9,en-GB;q=0.8,en;q=0.7,en-US;q=0.6',
  25. 'accept-encoding':'gzip, deflate, br',
  26. 'sec-fetch-mode':'navigate',
  27. 'sec-fetch-site':'same-origin',
  28. 'sec-fetch-user':'?1',
  29. 'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
  30. 'authority':'www.kickz.com'
  31. }
  32. ########################
  33.  
  34. print('\033[34m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Kickz Monitor')
  35. print('\033[34m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Made by Lulaba#7436')
  36.  
  37. def monitor(headers, mainUrl):
  38. max_retries=10
  39. for i in range(max_retries):
  40. try:
  41. proxy = proxylist.random_proxy()
  42. proxies = proxy.get_dict()
  43. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Starting...')
  44. html = requests.get(mainUrl, headers= headers, proxies= proxies, timeout= 5).text
  45. if html.status_code != 200:
  46. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + "ERROR, status code: " + str(html.status_code))
  47. continue
  48. else:
  49. pass
  50. if html.status_code == 200:
  51. print('\033[31m' +' [ '+ time.strftime('%H:%M:%S') + ' ] ' + "Signature: " + str(html.status_code))
  52. else:
  53. pass
  54.  
  55. except (TimeoutError, requests.exceptions.Timeout):
  56. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Timeout expired, thread restarted!')
  57. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Proxy used:' + proxies['http'])
  58. continue
  59.  
  60. except (requests.exceptions.ProxyError,requests.exceptions.ConnectionError):
  61. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Proxy error:' + proxies['http'])
  62. proxyNotify()
  63. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Switching proxies')
  64. continue
  65.  
  66. except Exception as e:
  67. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + "Unknown error, restarting: " + str(e))
  68. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + "Proxy used:" + proxies['http'])
  69. print('\033[31m' + ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + "Status code:" + str(html.status_code))
  70. continue
  71. else:
  72. exit()
  73.  
  74. soup = BeautifulSoup(html, 'lxml')
  75.  
  76. eskere = open('soup.txt', 'w', encoding='utf-8')
  77. eskere.write(str(soup))
  78. eskere.close
  79. print(' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'SOUP PRINTED !!')
  80.  
  81. availablesizes = []
  82. prodTitle = soup.find('h1', {'id':'prodNameId'}).get_text()
  83. prodImage = soup.find('img', {'alt':f'{prodTitle}'})['src']
  84. prodColor = soup.find('span', {'id':'variantColorId'}).get_text()
  85. prodSku = soup.find('span', {'id':'supplierArtNumSpan'}).get_text()
  86.  
  87. sizeList = soup.find('div', {'id':'1SizeContainer'})
  88.  
  89. for size in sizeList.findAll('a'):
  90. availablesizes.append(size['data-size'])
  91.  
  92. entry = {
  93. 'prodTitle': prodTitle,
  94. 'availablesizes': availablesizes
  95. }
  96.  
  97. if entry in db.all():
  98. print('The entry was a duplicate.' + '\n' + '--------------')
  99.  
  100. #If not a duplicate
  101. else:
  102. Model = Query()
  103. db.remove(Model['prodTitle'] == prodTitle)
  104. db.insert(entry)
  105. newNotify(hook, prodTitle, mainUrl, availablesizes, prodSku, prodColor, prodImage)
  106.  
  107. #Log
  108. print('\n'.join(map(str, availablesizes)))
  109.  
  110. def newNotify(hook, prodTitle, mainUrl, availablesizes, prodSku, prodColor, prodImage):
  111.  
  112. embed = Embed(
  113. color = 0x08e2ff,
  114. description = ''
  115. )
  116.  
  117. embed.set_title(title= f'{prodTitle}', url= f'{mainUrl}')
  118. embed.add_field(name= '**Color**', value = f'{prodColor}', inline = True)
  119. embed.add_field(name= '**Sku**', value = f'{prodSku}', inline = True)
  120. embed.add_field(name= '**Sizes**', value = '\n'.join(availablesizes), inline = False)
  121. embed.add_field(name= '**Quick Links**', value = '[**LOGIN**](https://www.kickz.com/it/user/login-show) | [**CART**](https://www.kickz.com/it/cart)', inline= False)
  122. embed.set_footer(text= ' [ '+ time.strftime('%H:%M:%S') + ' ] ' + '- Kickz by Lulaba#7436')
  123. embed.set_thumbnail(str(prodImage))
  124. hook.send(embed = embed)
  125. print(' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'Webhook sent to discord!')
  126.  
  127. def proxyNotify():
  128.  
  129. hook = Webhook('https://discordapp.com/api/webhooks/632896659256377385/TmxfcCDCECyjQF270MD3qZGB2l1x-WA4AcKTGdJ0lVoVoS_csVVVFzsvTlQjBBgiPrDJ', username = 'https://www.kickz.com', avatar_url = 'https://pbs.twimg.com/profile_images/592962053737951232/GOK0vBH5_400x400.jpg')
  130. hook.send(' [ '+ time.strftime('%H:%M:%S') + ' ] ' + 'PROXY ERROR OCCURED MAYBE NEED TO RESTART')
  131.  
  132. while True:
  133. monitor(headers, mainUrl)
  134. time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement