Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import requests
  3. import re
  4. import datetime
  5. import time
  6. import getpass
  7. from bs4 import BeautifulSoup
  8.  
  9. #Url to registration
  10. url = 'https://myschool.ru.is/myschool/?Page=Exe&ID=2.23&view=0&FagID=0&act=2&e='
  11. #Url to an event
  12. nurl = 'https://myschool.ru.is/myschool/?Page=Exe&ID=2.23&sID=2&e='
  13.  
  14. username = input('Username: ')
  15. password = getpass.getpass()
  16.  
  17. #Url to myschool frontpage used to find available events
  18. s = requests.get('https://myschool.ru.is/myschool/?Page=Front', auth=(username, password)).content.decode('ISO-8859-1')
  19.  
  20. #Check if password is correct
  21. soup = BeautifulSoup(s, 'html.parser')
  22. if soup.find('title').contents[0][:3] == '401':
  23. print('Wrong username or password')
  24. exit()
  25.  
  26.  
  27. #Pick an event
  28. c = re.findall('<td.*?Page=Exe&ID=2.23&sID=2&e=.*?td>',s)
  29. if len(c) == 0:
  30. print('There are no events available')
  31. exit()
  32.  
  33. print('The following events are available:')
  34. for k,i in enumerate(c):
  35. i = re.search('title=\'.*?\'', i)
  36. print(' {} - {}'.format(k, i.group()[7:-1]))
  37.  
  38. try:
  39. choice = int(input('Choose an event: '))
  40. except ValueError:
  41. print('Choose a number, you dingus!')
  42. exit()
  43.  
  44. #Get the event id
  45. try:
  46. c = c[choice]
  47. num = re.search('ID=2&e=.*?\"', c).group()[7:-1]
  48. except IndexError:
  49. print('That is an illegal choice, you dingus!')
  50. exit()
  51.  
  52. #Icelandic support by Kalli
  53. soup = BeautifulSoup(s, 'html.parser')
  54. name = soup.find('div', id='personname').contents[0].contents[0]
  55. registration_string = 'Registration starts:' if soup.find('a', id='icelandicbtn') else 'Skráning hefst:'
  56.  
  57. #Find time and date and check if some dungus is already registered
  58. s = requests.get(nurl+num, auth=(username, password)).content.decode('ISO-8859-1')
  59.  
  60. l = '\<strong\>%s\<\/strong\>' % name
  61. c = re.search(l,s)
  62. if c:
  63. print('You are already registered, you dingus!')
  64. exit(0)
  65.  
  66.  
  67. #We find the date to register
  68. soup = BeautifulSoup(s, 'html.parser')
  69. datelis = [i for i in soup.find_all('tr') if i('div', class_='ruPanelsLabel')]
  70.  
  71. for i in datelis:
  72. div = i('div', class_='ruPanelsLabel')[0]
  73. if div.contents and registration_string in div.contents[0]:
  74. i = i.getText().replace(registration_string,'').strip()
  75. day, hour = i.split()[1:]
  76. day = day.split('.')
  77. hour = hour.split(':')
  78. break
  79.  
  80.  
  81. #We start spamming approximately 2 minutes before registration starts
  82. date = datetime.datetime(int(day[2]),int(day[1]),int(day[0]),int(hour[0]),int(hour[1]))
  83. date = date - datetime.timedelta(minutes=2)
  84.  
  85. now = datetime.datetime.now()
  86. if now < date: print('Will start spamming at: {}'.format(date))
  87. while now < date:
  88. time.sleep(10)
  89. now = datetime.datetime.now()
  90.  
  91.  
  92. print('Starting registration spam')
  93. #Cool kids use while 1
  94. c = False
  95. while not c:
  96. #Try to register
  97. s = requests.get(url+num, auth=(username, password)).content
  98.  
  99. #We get some bytes back
  100. s = s.decode('ISO-8859-1')
  101.  
  102. #Are we registered\?
  103. l = '\<strong\>%s\<\/strong\>' % name
  104. c = re.search(l,s)
  105.  
  106. print('Done, you should now be registered!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement