I want to automatically attend online classes with Python + Selenium!

I want to attend online classes automatically

I think many students are taking online classes at this time.

I wondered if I could write an automatic attendance code if the attendance confirmation was an online class that only "attended a Zoom meeting".

As a reminder, it's a ** story **. Of course, ** Let's take the class properly! **Lol

Well, the main subject.

What I want to do is "** join the Zoom meeting before class time " and " leave the meeting just before the end of class time **".

As for the time, it seems quite so if you use sleep. The question is ** how to get into a meeting **.

Zoom can join the meeting from the browser, so I feel that the participation itself is quite likely if you can operate the browser.

Advance preparation

Python + selenium is used for browser operation. This is my first time to use selenium, but I learned it easily with Web scraping tutorial video in Python on Youtube.

By the way, Mac and Anaconada are already installed, Python 3.7.4. I used JupyterLab, but I don't have to.

Now that you know how to use it, you can host Zoom, start a test meeting, and get the URL.

For now, install selenium and open the URL.

test.py


#If it is not installed, install it.
!pip install selenium

from selenium import webdriver
import time

browser = webdriver.Chrome()
browser.implicitly_wait(3)

browser.get("Zoom test meeting URL")
time.sleep(5)

I opened it safely.

The following text will be displayed along with the meeting ID, etc. 「If you have Zoom Client installed, launch meeting. Otherwise, download and run Zoom.If you cannot download or run the application, join from your browser.」

If you try to join Zoom with a browser, it will be blocked by reCAPTCHA (bot countermeasure), so aim to start the installed Zoom.

In Chrome, right-click "Verify" and get the fullXpath of "launch meeting". After that, specify the element with xpath and click.

test.py


PATH='/html/body/div[2]/div/div/div/div/div[2]/h3[1]/a[1]'
launchButton = browser.find_element_by_xpath(PATH)
time.sleep(3)
launchButton.click()

When executed, "Do you want to open zoom.us? Cancel. Open zoom" Popup was displayed.

It looks like a confirmation pop-up (Confirm), so it seems quite so with switch_to.alert.

JavaScript alerts, prompts and confirmations

test.py


alert = browser.switch_to.alerttext = alert.text
alert.dismiss()

When you run Message: no such alert Nunu? ??

Pop step up

After checking and investigating various things, Selenium can only operate the JavaScripts pop-up, and what is displayed is the pattern of the system dialog.

Then, I found the description System dialog cannot be operated with Selenium.

Then, you can set it so that the system dialog is not displayed. So, refer to How to hide the confirmation screen when starting an external application in Chrome and omit the dialog when starting an external application. Set to.

defaults write com.google.Chrome ExternalProtocolDialogShowAlwaysOpenCheckbox -bool true

Operate the browser by yourself, set it so that the dialog will not be displayed from the next time, and execute it again with Selenium.

Failure. I get asked "Do you want to omit it from the next time onwards?" .. I wonder if it's the first time I visit the Zoom page in a window opened in Selenium.

Conclusion

I tried using Safari instead of Chrome, but it was blocked by a similar system dialog. I couldn't do it as I expected, but it was a good study because I used selenium for the first time. For the time being, one thing I can say is "** Let's attend the class properly !! **" that's all. (By the way, it's past 4 o'clock in the morning. Classes ...)

Postscript

I played with Chrome settings to hide the confirmation screen when starting an external application. However, I am a little worried about security, so I will fix it.

defaults write com.google.Chrome ExternalProtocolDialogShowAlwaysOpenCheckbox -bool false

When I executed, it remained hidden. After running, I quit Chrome, reopened it, deleted cookies, and then returned. Rest assured.

Recommended Posts

I want to automatically attend online classes with Python + Selenium!
I want to debug with Python
I want to analyze logs with Python
I want to play with aws with python
I want to make a game with Python
I want to use Temporary Directory with Python2
#Unresolved I want to compile gobject-introspection with Python3
I want to solve APG4b with Python (Chapter 2)
I want to write to a file with Python
I made a tool to automatically browse multiple sites with Selenium (Python)
I was addicted to scraping with Selenium (+ Python) in 2020
I want to inherit to the back with python dataclass
I want to work with a robot in python.
I tried to automatically generate a password with Python3
I want to AWS Lambda with Python on Mac!
[ML Ops] I want to do multi-project with Python
I want to run a quantum computer with Python
I want to be able to analyze data with Python (Part 3)
I want to specify another version of Python with pyvenv
I want to be able to analyze data with Python (Part 1)
I want to be able to analyze data with Python (Part 4)
I want to be able to analyze data with Python (Part 2)
[Python] I want to use the -h option with argparse
I want to do ○○ with Pandas
I want to use a wildcard that I want to shell with Python remove
I want to know the weather with LINE bot feat.Heroku + Python
I want to monitor UNIQLO + J page updates [Scraping with python]
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
A memorandum when I tried to get it automatically with selenium
I want to output the beginning of the next month with Python
I want to do a full text search with elasticsearch + python
I tried to make a periodical process with Selenium and Python
[Introduction] I want to make a Mastodon Bot with Python! 【Beginners】
How to automatically install Chrome Driver for Chrome version with Python + Selenium + Chrome
I tried to automatically collect images of Kanna Hashimoto with Python! !!
I tried to log in to twitter automatically with selenium (RPA, scraping)
I want to detect objects with OpenCV
I want to blog with Jupyter Notebook
I want to use jar from python
I wanted to solve ABC160 with Python
I want to build a Python environment
I want to pip install with PythonAnywhere
[Python] Automatically operate the browser with Selenium
I wanted to solve ABC172 with Python
I really wanted to copy with selenium
I want to do it with Python lambda Django, but I will stop
I want to tweet on Twitter with Python, but I'm addicted to it
(Python Selenium) I want to check the settings of the download destination of WebDriver
Environment maintenance made with Docker (I want to post-process GrADS in Python
[Outlook] I tried to automatically create a daily report email with Python
I want to do Dunnett's test in Python
I want to analyze songs with Spotify API 2
I wanted to solve NOMURA Contest 2020 with Python
I want to memoize including Python keyword arguments
I want to create a window in Python
[Python] I want to manage 7DaysToDie from Discord! 1/3
I want to mock datetime.datetime.now () even with pytest!
I want to knock 100 data sciences with Colaboratory
I wanted to install Python 3.4.3 with Homebrew + pyenv
I want to be an OREMO with setParam!
I tried to get CloudWatch data with Python