A system that automatically attends university zoom classes

Preface

Let's avoid misuse such as not accessing and attending with this Try not to attack the university lesson system such as manaba, and follow the manners of access.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from datetime import datetime

four_time=str(datetime.now().strftime("%H%M"))
four_time=int(four_time)

#Data preparation(Change to suit your subject)
data={"Monday":{1:"Family welfare theory",3:"Welfare and living environment theory"},"Tuesday":{2:"Advocacy and adult guardianship"},"Wednesday":{2:"Social Welfare Specialized Exercise I"},
      "Thursday":{1:"Mental health and welfare systems and services",3:"Social welfare survey training",5:"Social work exercise II"},"Friday":{1:"Community welfare theory",2:"Social work training guidance"}}

youbi=datetime.now().strftime('%A')


#Open your browser.
driver_path = './chromedriver'
driver = webdriver.Chrome(driver_path)
#Open the Google search TOP screen.
driver.get("Enter the manaba URL of your university")
#Wait 1 second
time.sleep(1)
#Enter your login ID

login_id = driver.find_element_by_id("mainuserid")
login_id.send_keys("Enter your student ID number")

login_id = driver.find_element_by_name("password")
login_id.send_keys("Enter password")


#Click the login button
next_btn = driver.find_element_by_name("login")
next_btn.click()

#Wait 1 second
time.sleep(1)

youbi_list = data[youbi]
four_time=1320

if four_time <= 950:
    class_name = youbi_list[1]
elif 1025<= four_time<=1050:
    class_name = youbi_list[2]
elif 1245<= four_time<=1330:  
    class_name = youbi_list[3]
elif 1610<= four_time<=1659:  
    class_name = youbi_list[4]
elif 1600<= four_time<=1659:  
    class_name = youbi_list[5]


print(four_time)
    
print(class_name)


continue_link = driver.find_element_by_link_text(class_name)
continue_link.click()


try:
    driver.find_element_by_partial_link_text(u"ZOOM").click()
except:
    try:
        driver.find_element_by_partial_link_text(u"zoom").click()
    except:
        try:
            driver.find_element_by_partial_link_text(u"Zoom").click()
        except:
            try:
                driver.find_element_by_partial_link_text(u"URL").click()
            except:
                driver.find_element_by_partial_link_text(u"url").click()

                
time.sleep(3)   

links = driver.find_elements_by_partial_link_text('zoom')
for elem in links:
    elem.click()
    
time.sleep(3)   
    
cur_url = driver.current_url
print(cur_url)


#Below beutiful-soup is used

import requests
from bs4 import BeautifulSoup

#Send a request to the URL to be scraped and get the HTML
res = requests.get(cur_url)

#Create a BeautifulSoup object from the response HTML
soup = BeautifulSoup(res.text, 'html.parser')

#Go to zoom page
s = soup.find('input')
s=str(s)
#It ’s too powerful, so it ’s stylish later.
s=s[39:-3]
driver.get(s)

Rough flow

Access 1, manaba URL with selenium and log in 2, get the current time and day of the week 3, Jump to the class frame that suits the time 4, Get the zoom URL 5, jump to zoom page I couldn't get the URL for the 6,zoom meeting as it was, so I got html and analyzed it once with Beautiful Soup. Get the meeting URL from 7, html 8, jump to the meeting page

Library installation

from selenium import webdriver from selenium.webdriver.common.keys import Keys import time from datetime import datetime

four_time=str(datetime.now().strftime("%H%M")) four_time=int(four_time)

Data preparation (including days of the week and class frames)

data = {"Monday": {1: "Family Welfare Theory", 3: "Welfare and Living Environment Theory"}, "Tuesday": {2: "Advocacy and Adult Guardianship System"}, "Wednesday": {2: "Social Welfare Specialized Exercise I"}, "Thursday": {1: "Psychiatric Social Welfare Systems and Services", 3: "Social Welfare Survey Practice", 5: "Social Work Exercise II"}, "Friday": {1: "Community Welfare Theory", 2 : "Social work training"}}

youbi=datetime.now().strftime('%A')

Open your browser.

driver_path = './chromedriver' driver = webdriver.Chrome(driver_path)

driver.get ("Enter the URL of the manaba of each university")

Wait 1 second

time.sleep(1)

Enter your login ID

login_id = driver.find_element_by_id("mainuserid") login_id.send_keys ("Enter your student ID number")

login_id = driver.find_element_by_name("password") login_id.send_keys ("Enter password")

Click the login button

next_btn = driver.find_element_by_name("login") next_btn.click()

Wait 1 second

time.sleep(1)

youbi_list = data[youbi] four_time=1320

if four_time <= 950: class_name = youbi_list[1] elif 1025<= four_time<=1050: class_name = youbi_list[2] elif 1245<= four_time<=1330:
class_name = youbi_list[3] elif 1610<= four_time<=1659:
class_name = youbi_list[4] elif 1600<= four_time<=1659:
class_name = youbi_list[5]

print(four_time)

print(class_name)

continue_link = driver.find_element_by_link_text(class_name) continue_link.click()

Look for the ZOOM link.

Refactoring is required here as it is not good with brute force try: driver.find_element_by_partial_link_text(u"ZOOM").click() except: try: driver.find_element_by_partial_link_text(u"zoom").click() except: try: driver.find_element_by_partial_link_text(u"Zoom").click() except: try: driver.find_element_by_partial_link_text(u"URL").click() except: driver.find_element_by_partial_link_text(u"url").click()

time.sleep(3)

links = driver.find_elements_by_partial_link_text('zoom') for elem in links: elem.click()

time.sleep(3)

Get the URL of the current page

cur_url = driver.current_url print(cur_url)

Below beutiful-soup is used

import requests from bs4 import BeautifulSoup

Send a request to the URL to be scraped and get the HTML

res = requests.get(cur_url)

Create a BeautifulSoup object from the response HTML

soup = BeautifulSoup(res.text, 'html.parser')

zoom Open the meeting URL

s = soup.find('input') s=str(s) The following refactoring is required for too much skill s=s[39:-3]

driver.get(s)

Recommended Posts

A system that automatically attends university zoom classes
PGM that automatically creates a walking route
Nogizaka46 A program that automatically saves blog images
A Vim plugin that automatically formats Python styles
A simple system that automatically shoots with object detection and sends it to LINE