Guest User

Untitled

a guest
Nov 18th, 2020
258
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. import re
  3. import time
  4. import sys
  5. import os
  6. from progress.bar import IncrementalBar
  7.  
  8. os.system('cls' if os.name == 'nt' else 'clear')
  9.  
  10. print('Created By Mimky')
  11. SIDinput = input("\nEnter Steam ID: ")
  12. SID = '#' + str(SIDinput)
  13.  
  14. logs_prof = 'https://logs.tf/profile/' + SIDinput
  15. logs = requests.get(logs_prof).text
  16.  
  17. results = re.search('<p>(.*?)</p>', logs)
  18. p_name = re.search('<title>(.*?)</title>', logs)
  19.  
  20. try:
  21.     log_count = int(''.join(i for i in results.group(1) if i.isdigit()))
  22. except:
  23.     print('\nInvald Steam ID or No Logs on Account.')
  24.     input('\n\nPress Enter to Quit...')
  25.     sys.exit()
  26.  
  27. if log_count > 25:
  28.     total_pages = int(log_count / 25) + 1
  29. else:
  30.     total_pages = 1
  31.  
  32. print('\n\n' + str(total_pages) + ' Pages and ' + str(log_count) + ' Logs Found for Player: ' + p_name.group(1)[:-10])
  33.  
  34. eta_checker = log_count * 0.795
  35. print('\nEstimated Search Time: ' + str(round(eta_checker / 60)) + ' minutes ' + str(round(eta_checker % 60)) + ' seconds.')
  36.  
  37.  
  38. log_lst_str = []
  39. bar = IncrementalBar('Preparing for Iteration', max=total_pages + 1, suffix='%(percent)d%%')
  40. for i in range(total_pages + 1):
  41.     logs_pages = requests.get(logs_prof + '?p=' + str(i)).text
  42.     log_lst_str.append(re.findall('<td><a href="/(.*)' + SID, logs_pages))
  43.     bar.next()
  44. bar.finish()
  45. print('\n')
  46. log_lst_str.pop(0)
  47. log_lst = [item for sublist in log_lst_str for item in sublist]
  48.  
  49. DPM_lst = []
  50. KD_lst = []
  51. kills_lst = []
  52. deaths_lst = []
  53. start_time = time.time()
  54. counter = 0
  55.  
  56.  
  57. search_term_start = '''<tr id="player_''' + SIDinput + '''">'''
  58. search_term_end = '''<tr id="player_'''
  59. search_term_fixer = '''</table></div>'''
  60.  
  61. for i in log_lst:
  62.     counter += 1
  63.     log_printer = 'https://logs.tf/' + i
  64.     log_iterator = requests.get(log_printer).text
  65.     print("Grabbing logs from: " "{} ({}%)".format(log_printer, round(100*counter/log_count, 1)))
  66.    
  67.     c = re.compile(search_term_start + r'(.*?)' + search_term_end, re.DOTALL)
  68.     try:
  69.         d = c.search(log_iterator).group(0)
  70.     except AttributeError:
  71.         c = re.compile(search_term_start + r'(.*?)' + search_term_fixer, re.DOTALL)
  72.         d = c.search(log_iterator).group(0)
  73.        
  74.     y1 = re.compile(search_term_start + r'(.*)' + '</table>"></i>', re.DOTALL)
  75.     y2 = y1.search(d).group(0)
  76.  
  77.     x1 = "".join(d.rsplit(y2))
  78.     x2 = re.compile('<td>' + r'(.*)' + re.escape('.') + r'(.*?)' + '</td>', re.DOTALL)
  79.     x3 = repr(x2.search(x1).group(0))
  80.     x4 = x3.replace(r'\n', '').replace(r'\t', '').replace('<td>', '').replace('</td>', ' ').split(' ')
  81.  
  82.     DPM = int(x4[-4])
  83.     KD = float(x4[-2])
  84.     kills = int(x4[0][1:])
  85.     deaths = int(x4[2])
  86.    
  87.     DPM_lst.append(DPM)
  88.     KD_lst.append(KD)
  89.     kills_lst.append(kills)
  90.     deaths_lst.append(deaths)
  91.  
  92. def time_convert(sec):
  93.   mins = sec // 60
  94.   sec = sec % 60
  95.   mins = mins % 60
  96.   return [int(mins), int(sec)]
  97.  
  98. end_time = time.time()
  99. time_lapsed = time_convert(end_time - start_time)
  100. os.system('cls' if os.name == 'nt' else 'clear')
  101. print('\n\n')
  102.  
  103. print('Total Time Elapsed: ' + str(time_lapsed[0]) + ' minutes ' + str(time_lapsed[1]) + ' seconds.\n')
  104.  
  105. print('Average DPM: ', round(sum(DPM_lst) / len(DPM_lst), 2))
  106. print('Average KD Ratio: ', round(sum(KD_lst) / len(KD_lst), 2))
  107. print('\nAverage Kills: ', round(sum(kills_lst) / len(kills_lst), 2))
  108. print('Average Deaths: ', round(sum(deaths_lst) / len(deaths_lst), 2))
  109. input('\n\nPress Enter to Quit...')
RAW Paste Data