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.
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.
test.py
alert = browser.switch_to.alerttext = alert.text
alert.dismiss()
When you run Message: no such alert Nunu? ??
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.
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 ...)
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