NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


import requests
import re
from pprint import pprint
from bs4 import BeautifulSoup
from time import gmtime, strftime

log_in_successful = False

# Keep trying until login successful
while(not log_in_successful):
# Prompt username and password
userid = input("Enter username: ")
if(userid=='d'):
username = 'desmondyeoh'
password = 'walao123'
elif(userid=='yq'):
username = 'yqlooi'
password = 'kambyyang'
elif(userid=='sw'):
username = 'shinw97'
password = 'yyjsbrdppzhkytzzjdqd'
elif(userid =='b'):
username = 'boon529'
password = '87157185chg'
elif(userid=='k'):
username = 'kamwoh'
password = 'n0cmg7y44'
else:
username = userid
password = input("Enter password: ")

# Log in User
login_url = 'http://register.um.edu.my/daftar/loginstud.asp'

login_data = {
'FormName':'Login',
'Nodaftar':username, 'Login':password,
'FormAction':'login',
'submit.x':'14',
'submit.y':'5',
'submit':'Login',
'ret_page':'',
'querystring':'',
}

session = requests.Session()
res = session.post(login_url, data=login_data)
res = session.get('''http://register.um.edu.my/daftar/daftar_elkok.asp?
tempoh_maks=''')
soup = BeautifulSoup(res.content, 'html.parser')
subject_details = [content.text for content in soup.select('font[size="1"]')][:-1]
subjects = list(zip(*[iter(subject_details)]*11))

is_logged_in = not len(re.findall('Username', res.text))

if is_logged_in:
log_in_successful = True;
else:
print("nnUsername/password incorrect. Please try again")

# view_timetable(subjects);


subj_code = input("Enter Subject Code: ").upper()


if subj_code in subject_details:
print("REGISTERED")
confirm = input("!!! Drop course? (Type "DROP" to confirm): ")
if confirm == "DROP":
drop_url = "http://register.um.edu.my/daftar/daftar_elkok.asp?tempoh_maks="
drop_data = {
'subjekgugur': "'" + subj_code + "'",
'Submit.x':'36',
'Submit.y':'6',
'Submit':'Gugur',
}
res = session.post(drop_url, data=drop_data)
print("COURSE DROPPPED")
else:
print("Course is NOT dropped.")

listsub_url_format = "http://register.um.edu.my/daftar/listsubjekkump.asp?subjek={}&tempoh_maks="
listsub_url = listsub_url_format.format(subj_code)

res = session.get(listsub_url)
soup = BeautifulSoup(res.content, 'html.parser')
group_details = [content.text for content in soup.select('font[size="1"]')][8:]
credit_hour = soup.find_all('td', width=27)[1].text
groups = list(zip(*[iter(group_details)]*7))
group_choices = group_details[1::7]

# print_subject_groups_in_table
print()
print("REGISTER SUBJECT GROUP")
print('CODE:t', groups[0][0])
print('SUBJ:t', groups[0][2])
print('C.HR:t', credit_hour.strip())
print('N_GP:t', len(groups))

row_format = '[{!s:3}] {!s:4} {!s:20} {!s:20} '
print()

print(row_format.format('G', 'DAY', 'TIME', 'VENUE'))
for group in groups:
print(row_format.format(group[1], group[3], group[4], group[5]))


# REGISTER GROUP
group_choice = input("Pick your group: ").strip().upper()

def register_group(group_choice):
register_url = "http://register.um.edu.my/daftar/daftar_elkok.asp?tempoh_maks=&subjek="+subj_code

register_data = {
'radiosubjek':group_choice,
'Submit':'Submit',
}

res = session.get(register_url, data=register_data)

is_time_overlap = len(re.findall('overlaps in terms of', res.text))
is_group_max = len(re.findall('reached its maximum capacity', res.text))

print(strftime('%H:%M:%S', gmtime()), end=' ')

if is_time_overlap:
print("G" + group_choice + " overlapped")
return 'OLP'
elif is_group_max:
print("G" + group_choice + " full")
return 'FULL'
else:
print("G" + group_choice + " registered!!")
return 'REG'

if group_choice == 'ALL':
def register_group_choices():
i = 0
while True:
i += 1
print(i)
for choice in group_choices:
res = register_group(choice)
if res == 'REG':
return
elif res == 'OLP':
group_choices.remove(choice)

register_group_choices()

elif group_choice in group_choices:
while register_group(group_choice) == 'FULL':
pass

else:
print("Group""+group_choice+"" does not exists.")


# CONFIRM ALL REGISTER COURSE
# confirm_register_url = "http://register.um.edu.my/daftar/daftar_elkok.asp?tempoh_maks="
confirm_register_url = "http://register.um.edu.my/daftar/simpan_daftar_kursus.asp?tempoh_maks="
res = session.post(confirm_register_url)
print(strftime('%H:%M:%S', gmtime()), end=' ')
print("Confirmed Register all Courses")

# get, print registered subjects
res = session.get('''http://register.um.edu.my/daftar/daftar_elkok.asp?
tempoh_maks=''')
soup = BeautifulSoup(res.content, 'html.parser')
subject_details = [content.text for content in soup.select('font[size="1"]')][:-1]
subjects = list(zip(*[iter(subject_details)]*11))



# PRINT REGISTERED SUBJECTS IN TABLE
print(subjects)
row_format = '{!s:40} {!s:7}/{!s:2} {!s:4} {!s:17} {!s:17} {!s:1} {!s:18} {!s:1}'
print(row_format.format('SUBJECT', 'CODE', 'G',
'DAY', 'TIME', 'VENUE', 'C', 'EXAM', 'S'))
for subj in subjects:
row = row_format.format(subj[1][:40], subj[0], subj[2],
subj[4], subj[5], subj[6], subj[3], subj[7], subj[10][:1])
print(row)
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.