Advertisement
Aksyo

Untitled

Sep 10th, 2022
1,142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.11 KB | None | 0 0
  1. from datetime import datetime
  2. import requests
  3. import time
  4. import json
  5.  
  6. timestampAFTER=1661990400
  7. timestampBEFORE=1664668800
  8.  
  9. timeNOW = datetime.now().date()
  10. time_r = f'{timeNOW}'.split('-')
  11. time_p = '[{}.{}.{}]'.format(time_r[2], time_r[1], time_r[0])
  12. print(time_p)
  13.  
  14. s = requests.get('https://vimetop.ru/moders')
  15. j = str(s.content)
  16. moderlist = j.split('<script>var moders_list = ')[1]
  17. moderlist = moderlist.split(';</script>')[0]
  18. res = json.loads(moderlist)
  19. moders = [i for i in res.keys()]
  20. print(moders)
  21.  
  22. mods = ['Alice_2', 'D_3_N_4_K', 'VerM3L', 'FuNNyman', 'TBO9I_HaBEKU', 'Flash_Gaming_', 'constellationn', 'Mr_AHrEJL', 'AlesteZ']
  23. preds = {}
  24.  
  25.  
  26. for moder in moders:
  27.     s = requests.get(f'https://forum.vimeworld.com/search/?&q=Меры%20Закрыто%20принята%20отклонена&type=forums_topic&author={moder}&nodes=41&search_and_or=or&start_after={timestampAFTER}&start_before={timestampBEFORE}&updated_after={timestampAFTER}&updated_before={timestampBEFORE}&sortby=relevancy')
  28.     t = str(s.content)
  29.     t = t.split(' ')
  30.     try:
  31.         index = t.index('\\xd1\\x80\\xd0\\xb5\\xd0\\xb7\\xd1\\x83\\xd0\\xbb\\xd1\\x8c\\xd1\\x82\\xd0\\xb0\\xd1\\x82</p>\\n<div')-1 # 1 результат
  32.         count = t[index]
  33.         count = count.replace('\\xe2\\x80\\xaf', '')
  34.         preds[moder] = count.replace('\\xc2\\xa0', '')
  35.     except:
  36.         try:
  37.             index = t.index('\\xd1\\x80\\xd0\\xb5\\xd0\\xb7\\xd1\\x83\\xd0\\xbb\\xd1\\x8c\\xd1\\x82\\xd0\\xb0\\xd1\\x82\\xd0\\xbe\\xd0\\xb2</p>\\n<div')-1 #5 - 20 результатов
  38.             count = t[index]
  39.             count = count.replace('\\xe2\\x80\\xaf', '')
  40.             preds[moder] = count.replace('\\xc2\\xa0', '')
  41.         except:
  42.             try:
  43.                 index = t.index('\\xd1\\x80\\xd0\\xb5\\xd0\\xb7\\xd1\\x83\\xd0\\xbb\\xd1\\x8c\\xd1\\x82\\xd0\\xb0\\xd1\\x82\\xd0\\xb0</p>\\n<div')-1 # 2, 3, 4 результата
  44.                 count = t[index]
  45.                 count = count.replace('\\xe2\\x80\\xaf', '')
  46.                 preds[moder] = count.replace('\\xc2\\xa0', '')
  47.             except:
  48.                 pass
  49.     print(f'Progress [{moders.index(moder)+1}/{len(moders)}]')
  50.  
  51. for moder in preds.keys():
  52.     preds[moder] = int(preds[moder])
  53.  
  54. sorted_tuple = sorted(preds.items(), key = lambda x: int(x[1]))
  55. sorted_tuple_reversed = reversed(sorted_tuple)
  56. sorted_dict = dict(sorted_tuple_reversed)
  57.  
  58.  
  59. for moder in sorted_dict:
  60.     print(f'{moder} закрыл {preds[moder]} жалоб за месяц. {time_p}')
  61.  
  62.  
  63. # link 2 - https://forum.vimeworld.com/search/?&q=Меры%20Закрыто%20принята%20отклонена&type=forums_topic&quick=1&author={moder}&nodes=9&search_and_or=or&start_after=1654041600&start_before=1656633600&updated_after=1654041600&updated_before=1656633600&sortby=relevancy
  64.  
  65. preds = {}
  66.  
  67. for moder in mods:
  68.     s = requests.get(f'https://forum.vimeworld.com/search/?&q=Меры%20Закрыто%20принята%20отклонена&type=forums_topic&quick=1&author={moder}&nodes=9&search_and_or=or&start_after={timestampAFTER}&start_before={timestampBEFORE}&updated_after={timestampAFTER}&updated_before={timestampBEFORE}&sortby=relevancy')
  69.     t = str(s.content)
  70.     t = t.split(' ')
  71.     try:
  72.         index = t.index('\\xd1\\x80\\xd0\\xb5\\xd0\\xb7\\xd1\\x83\\xd0\\xbb\\xd1\\x8c\\xd1\\x82\\xd0\\xb0\\xd1\\x82</p>\\n<div')-1 # 1 результат
  73.         count = t[index]
  74.         preds[moder] = count.replace('\\xc2\\xa0', '')
  75.     except:
  76.         try:
  77.             index = t.index('\\xd1\\x80\\xd0\\xb5\\xd0\\xb7\\xd1\\x83\\xd0\\xbb\\xd1\\x8c\\xd1\\x82\\xd0\\xb0\\xd1\\x82\\xd0\\xbe\\xd0\\xb2</p>\\n<div')-1 #5 - 20 результатов
  78.             count = t[index]
  79.             preds[moder] = count.replace('\\xc2\\xa0', '')
  80.         except:
  81.             try:
  82.                 index = t.index('\\xd1\\x80\\xd0\\xb5\\xd0\\xb7\\xd1\\x83\\xd0\\xbb\\xd1\\x8c\\xd1\\x82\\xd0\\xb0\\xd1\\x82\\xd0\\xb0</p>\\n<div')-1 # 2, 3, 4 результата
  83.                 count = t[index]
  84.                 preds[moder] = count.replace('\\xc2\\xa0', '')
  85.             except:
  86.                 pass
  87.     print(f'Progress [{mods.index(moder)+1}/{len(mods)}]')
  88.  
  89. sorted_tuple = sorted(preds.items(), key = lambda x: int(x[1]))
  90. sorted_tuple_reversed = reversed(sorted_tuple)
  91. sorted_dict = dict(sorted_tuple_reversed)
  92.  
  93. for moder in sorted_dict:
  94.     print(f'{moder} закрыл {preds[moder]} жалоб за месяц. {time_p}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement