Advertisement
Guest User

Untitled

a guest
May 28th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.01 KB | None | 0 0
  1. async def scrape_and_vote(bot):
  2.     has_voted_annie = 1
  3.     count_annie = 0
  4.     while not bot.is_closed:
  5.         try:
  6.             res = requests.get('http://gameinfo.saltyteemo.com/')
  7.             res.raise_for_status()
  8.         except res.exceptions.HTTPError:
  9.             await asyncio.sleep(120)
  10.             res = requests.get('http://gameinfo.saltyteemo.com/')
  11.             res.raise_for_status()
  12.         table = bs4.BeautifulSoup(res.text, "html.parser")
  13.         type(table)
  14.         count = -1
  15.         user_list = []
  16.         timeS = time.time()
  17.         for text2 in table.find_all('tr'):
  18.             count += 1
  19.             champion_list = text2.find_all('br')
  20.             user_list = text2.find_all('td', class_="leagues")
  21.             user_list = [ele.text.strip() for ele in user_list]
  22.             champion_list = [ele.text.strip() for ele in champion_list]
  23.             if count == 1:
  24.                 champion_list.remove('Level 30')
  25.                 blue_one = champion_list
  26.             elif count == 2:
  27.                 champion_list.remove('Level 30')
  28.                 blue_two = champion_list
  29.             elif count == 3:
  30.                 champion_list.remove('Level 30')
  31.                 blue_three = champion_list
  32.             elif count == 4:
  33.                 champion_list.remove('Level 30')
  34.                 blue_four = champion_list
  35.             elif count == 5:
  36.                 champion_list.remove('Level 30')
  37.                 blue_five = champion_list
  38.             elif count == 6:
  39.                 champion_list.remove('Level 30')
  40.                 red_one = champion_list
  41.             elif count == 7:
  42.                 champion_list.remove('Level 30')
  43.                 red_two = champion_list
  44.             elif count == 8:
  45.                 champion_list.remove('Level 30')
  46.                 red_three = champion_list
  47.             elif count == 9:
  48.                 champion_list.remove('Level 30')
  49.                 red_four = champion_list
  50.             elif count == 10:
  51.                 champion_list.remove('Level 30')
  52.                 red_five = champion_list
  53.  
  54.  
  55.         try:
  56.             blue = blue_one + blue_two + blue_three + blue_four + blue_five
  57.             red = red_one + red_two + red_three + red_four + red_five
  58.  
  59.             if blue.count('Annie') == 1 and red.count('Annie') != 1 and has_voted_annie == 0:
  60.                 ABlue.vote()
  61.                 count_annie += 1
  62.                 has_voted_annie = 1
  63.             elif red.count('Annie') == 1 and blue.count('Annie') != 1 and has_voted_annie == 0:
  64.                 ARed.vote()
  65.                 count_annie += 1
  66.                 has_voted_annie = 1
  67.             elif blue.count("Annie") == 0 and red.count("Annie") == 0 and has_voted_annie == 1:
  68.                 print("Reset Annie Vote")
  69.                 has_voted_annie = 0
  70.             else:
  71.                 print("Game in progress.")
  72.  
  73.             await asyncio.sleep(120)
  74.         except NameError as e:
  75.             print("No active game")
  76.             has_voted_annie = 0
  77.             await asyncio.sleep(120)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement