自动加入Google Meeting会议 [英] join google meet meetings automatically

查看:191
本文介绍了自动加入Google Meeting会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑一个简单的python自动化脚本,该脚本将在特定时间打开并通过该链接进入Google Meet Meeting.

I was thinking about a simple python automation script that will open and enter a google meet meeting via the link at a specific time.

我只是在学习,有人可以帮我吗

I am just learning, can anybody help me out

推荐答案

我知道这并不是一个很好的答案,但是我也使用Google Meets.我在想同样的事情.讲到我的观点,尝试使用一个名为 selenium 的python库.我每天都用它来自动化日常的Web事情.

I know this isn't much of an answer, but I also use google meets. I was thinking of the same thing. Getting on to my point, try using a python library called selenium. I use it to automate daily web things every day.

我认为它在linux上效果最佳,因为linux有一个名为 crontab 或类似的东西.

In my opinion it works best on linux because linux has a service called crontab or something like that..

我知道这有点...对于堆栈溢出来说是非常规的,但是如果您愿意的话,我可以在编写完代码后在此处发布我的代码.我说非常规的原因是因为这需要一些时间.

I know this is a bit...unconventional for Stack Overflow, but if you're willing to, I could post my code here when I am done writing it. The reason I say unconventional, is because it will take some time.

我完成了代码……比我预期的要早.暂时:

I finished the code...earlier than I expected. For the time being it ONLY:

  1. 使用普通的Google帐户 OR 登录到具有Active Directory登录名的Google帐户.
  2. 使用后备循环以确保该程序可在慢速wifi上运行,因为并非我们所有人都拥有5G.
  3. 登录Google后打开Goog​​le Meets.(相信我,这样做很棘手... Google不喜欢人们自主地登录事物)
  1. Logs into Google with a normal google account OR with a google account with an Active Directory login.
  2. Uses fallback loops to ensure that the program works on slow wifi because, not all of us have 5G yet.
  3. Opens Google Meets after signing into Google. (Trust me, it was tricky doing this...Google doesn't like people autonomously signing into things)

我的"TODO"列表:

  1. 我将让该计划在任何预定的聚会中查看Google聚会,并在5分钟前参加.(预计项目时间-1天)

下面是代码,经过一些调整后,它应该可以在Windows,Mac OS和任何其他系统上运行.我目前正在将Firefox与硒结合使用...只是我的建议,但我建议您也这样做.

Below is the code, with some adjustments it should work on Windows, Mac OS, and any other system. I'm currently using Firefox with selenium...just my advice, but I advise that you do the same.

如果您想知道为什么我保留 USE_FAILSAFE_PERCAUTIONS ,那是因为每当我使用 driver.implicitly_wait()时,程序都会失败.如果有人知道如何正确使用它,它将比 time.sleep()有用.

If you're wondering why I kept USE_FAILSAFE_PERCAUTIONS, it's because the program fails whenever I use driver.implicitly_wait(). If someone knows how to properly use it, it would be more useful than time.sleep().

import selenium, os, time, datetime, random, warnings, sys
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

warnings.filterwarnings("ignore", category=DeprecationWarning) 
print("Timestamp: " + datetime.datetime.now().strftime("%D  %H:%M:%S"))

AUTOMATION_FAILED = False
USE_FAILSAFE_PERCAUTIONS = True
EMAIL_ADDRESS = ""
AD_USERNAME = None # Leave blank or put 'None' to use a regular Google account
AD_PASSWORD = ""


options = Options()
options.headless = False

profile = webdriver.FirefoxProfile()
binary = FirefoxBinary('/usr/lib/firefox-esr/firefox-esr') # Absolute path to Firefox executable
driver = webdriver.Firefox(profile, options=options, firefox_binary=binary)
driver.maximize_window()
driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier")
print("Successfully loaded Google Authetication point! [Gmail]")

time.sleep(2)

if AUTOMATION_FAILED == False:
    for i in range(6):
        try:
            driver.find_element_by_id("identifierId").send_keys(EMAIL_ADDRESS)
            driver.find_element_by_id("identifierNext").click()
            print("Sucessfully uploaded email...")
            break
        except selenium.common.exceptions.NoSuchElementException:
            print("[ERROR]: Attempting to resend email address.")
            if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
            else: driver.implicitly_wait(6)
        except selenium.common.exceptions.WebDriverException as e:
            print("[ERROR]: Web driver error.\n[ERROR DETAILS]:",e)
            AUTOMATION_FAILED = True
            break

if AUTOMATION_FAILED == False:
    if AD_USERNAME == "" or AD_USERNAME == None:
        for i in range(6):
            try:
                driver.find_element_by_name("password").send_keys(AD_PASSWORD)
                driver.find_element_by_id("passwordNext").click()
                print("Sucessfully sent credentials...")
                break
            except selenium.common.exceptions.NoSuchElementException:
                print("[ERROR]: Attempting to find password input.")
                if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
                else: driver.implicitly_wait(6)
    else:
        for i in range(6):
            try:
                driver.find_element_by_id("userNameInput").send_keys(AD_USERNAME)
                driver.find_element_by_id("passwordInput").send_keys(AD_PASSWORD)
                driver.find_element_by_id("submitButton").click()
                print("Sucessfully sent Active Directory credentials...")
                break
            except selenium.common.exceptions.NoSuchElementException:
                print("[ERROR]: Attempting to find active directory login elements.")
                if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
                else: driver.implicitly_wait(6)
            except selenium.common.exceptions.WebDriverException as e:
                print("[ERROR]: Web driver error.\n[ERROR DETAILS]:",e)
                AUTOMATION_FAILED = True
                break

time.sleep(2)
print("Loading Google Meets...")
driver.get("https://meet.google.com")
driver.refresh()

更新3

在程序加载网站时,我将其加入到它遇到的第一次会议的地步,例如:如果按钮位于显示使用会议代码"的按钮的正下方,则该程序将加入英语".在需要英语的时候,可以很容易地将其重新配置为加入.

Update 3

I got it to the point where the program joins the first meet it finds when you load the website, for example: if "English" is right below the button that says "Use a meeting code", the program will join "English". It can easily be reconfigured to join when it is time for English.

该程序还可以通过按 CTRL + d 关闭麦克风,并通过按 CTRL + e 关闭相机.同样,可以为Mac OS重新配置它.

The program also turns off your microphone by pressing CTRL + d, and turns off your camera by pressing CTRL + e. Again, this can be reconfigured for Mac OS.

import selenium, os, time, datetime, random, warnings, sys
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

warnings.filterwarnings("ignore", category=DeprecationWarning) 
print("Timestamp: " + datetime.datetime.now().strftime("%D  %H:%M:%S"))

AUTOMATION_FAILED = False
USE_FAILSAFE_PERCAUTIONS = True
EMAIL_ADDRESS = ""
AD_USERNAME = ""
AD_PASSWORD = ""


options = Options()
options.headless = False

profile = webdriver.FirefoxProfile()
binary = FirefoxBinary('/usr/lib/firefox-esr/firefox-esr') # Absolute path to Firefox executable
driver = webdriver.Firefox(profile, options=options, firefox_binary=binary)
driver.maximize_window()
driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier")
print("Successfully loaded Google Authetication point! [Gmail]")

time.sleep(2)

if AUTOMATION_FAILED == False:
    for i in range(6):
        try:
            driver.find_element_by_id("identifierId").send_keys(EMAIL_ADDRESS)
            driver.find_element_by_id("identifierNext").click()
            print("Sucessfully uploaded email...")
            break
        except selenium.common.exceptions.NoSuchElementException:
            print("[ERROR]: Attempting to resend email address.")
            if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
            else: driver.implicitly_wait(6)
        except selenium.common.exceptions.WebDriverException as e:
            print("[ERROR]: Web driver error.\n[ERROR DETAILS]:",e)
            AUTOMATION_FAILED = True
            break

if AUTOMATION_FAILED == False:
    if AD_USERNAME == "" or AD_USERNAME == None:
        for i in range(6):
            try:
                driver.find_element_by_name("password").send_keys(AD_PASSWORD)
                driver.find_element_by_id("passwordNext").click()
                print("Sucessfully sent credentials...")
                break
            except selenium.common.exceptions.NoSuchElementException:
                print("[ERROR]: Attempting to find password input.")
                if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
                else: driver.implicitly_wait(6)
    else:
        for i in range(6):
            try:
                driver.find_element_by_id("userNameInput").send_keys(AD_USERNAME)
                driver.find_element_by_id("passwordInput").send_keys(AD_PASSWORD)
                driver.find_element_by_id("submitButton").click()
                print("Sucessfully sent Active Directory credentials...")
                break
            except selenium.common.exceptions.NoSuchElementException:
                print("[ERROR]: Attempting to find active directory login elements.")
                if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
                else: driver.implicitly_wait(6)
            except selenium.common.exceptions.WebDriverException as e:
                print("[ERROR]: Web driver error.\n[ERROR DETAILS]:",e)
                AUTOMATION_FAILED = True
                break

time.sleep(2)
print("Loading Google Meets...")
driver.get("https://meet.google.com")
#driver.refresh()


a = driver.find_elements_by_class_name("mobgod")
print(len(a))
a[0].click()

time.sleep(7) # Ensure that the browser fully loads the next part.

for i in range(6):
    try:
        WebDriverWait(driver, 36).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Join now')]")))

        time.sleep(2)
        turn_off_mic_action = ActionChains(driver)
        turn_off_mic_action.key_down(Keys.CONTROL).send_keys("d").key_up(Keys.CONTROL).perform();
        turn_off_camera_action = ActionChains(driver)
        turn_off_camera_action.key_down(Keys.CONTROL).send_keys("e").key_up(Keys.CONTROL).perform();
        print("Sucessfully found landmark...turned off camera and microphone.")
        break
    except selenium.common.exceptions.TimeoutException:
        print("[ERROR]: Attempting to find landmark...")
        if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
        else: driver.implicitly_wait(6)

try:
    join_button = WebDriverWait(driver, 36).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Join now')]")))
    driver.execute_script("arguments[0].click();", join_button)
except selenium.common.exceptions.TimeoutException:
    try:
        join_button = WebDriverWait(driver, 36).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Ask to join')]")))
        driver.execute_script("arguments[0].click();", join_button)
    except selenium.common.exceptions.TimeoutException:
        print("Couldn't join Google Meet.")

更新3(真实)

此更新包括使用代码的能力,仅此而已.以前的版本主要依赖于具有与Google Active Directory服务关联的Google帐户....现在很幸运,您可以使用您的个人帐户.

Update 3 (For Real)

This update includes the ability to use a code instead, that's about it. The previous versions rely mostly on having a Google account that is connected with Google's Active Directory service. ...lucky for you now in this update, you can use your personal account.

import selenium, os, time, datetime, random, warnings, sys
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

warnings.filterwarnings("ignore", category=DeprecationWarning) 
print("Timestamp: " + datetime.datetime.now().strftime("%D  %H:%M:%S"))

AUTOMATION_FAILED = False
USE_FAILSAFE_PERCAUTIONS = True
CLASS_CODE = ""
EMAIL_ADDRESS = ""
AD_USERNAME = ""
AD_PASSWORD = ""


options = Options()
options.headless = False

profile = webdriver.FirefoxProfile()
binary = FirefoxBinary('/usr/lib/firefox-esr/firefox-esr') # Absolute path to Firefox executable
driver = webdriver.Firefox(profile, options=options, firefox_binary=binary)
driver.maximize_window()
driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier")
print("Successfully loaded Google Authetication point! [Gmail]")

time.sleep(2)

if AUTOMATION_FAILED == False:
    for i in range(6):
        try:
            driver.find_element_by_id("identifierId").send_keys(EMAIL_ADDRESS)
            driver.find_element_by_id("identifierNext").click()
            print("Sucessfully uploaded email...")
            break
        except selenium.common.exceptions.NoSuchElementException:
            print("[ERROR]: Attempting to resend email address.")
            if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
            else: driver.implicitly_wait(6)
        except selenium.common.exceptions.WebDriverException as e:
            print("[ERROR]: Web driver error.\n[ERROR DETAILS]:",e)
            AUTOMATION_FAILED = True
            break

if AUTOMATION_FAILED == False:
    if AD_USERNAME == "" or AD_USERNAME == None:
        for i in range(6):
            try:
                driver.find_element_by_name("password").send_keys(AD_PASSWORD)
                driver.find_element_by_id("passwordNext").click()
                print("Sucessfully sent credentials...")
                break
            except selenium.common.exceptions.NoSuchElementException:
                print("[ERROR]: Attempting to find password input.")
                if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
                else: driver.implicitly_wait(6)
    else:
        for i in range(6):
            try:
                driver.find_element_by_id("userNameInput").send_keys(AD_USERNAME)
                driver.find_element_by_id("passwordInput").send_keys(AD_PASSWORD)
                driver.find_element_by_id("submitButton").click()
                print("Sucessfully sent Active Directory credentials...")
                break
            except selenium.common.exceptions.NoSuchElementException:
                print("[ERROR]: Attempting to find active directory login elements.")
                if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
                else: driver.implicitly_wait(6)
            except selenium.common.exceptions.WebDriverException as e:
                print("[ERROR]: Web driver error.\n[ERROR DETAILS]:",e)
                AUTOMATION_FAILED = True
                break

time.sleep(2)
print("Loading Google Meets...")
driver.get("https://meet.google.com")
#driver.refresh()


a = driver.find_elements_by_class_name("mobgod")
print(len(a))

if len(a) != 0:
    a[0].click()

if AD_USERNAME == "" or AD_USERNAME == None:
    for i in range(6):
        try:
            driver.find_element_by_id("i3").send_keys(CLASS_CODE)
            press_enter = ActionChains(driver)
            press_enter.key_down(Keys.ENTER).key_up(Keys.ENTER).perform();
            print("Sucessfully uploaded meeting code.")
            break
        except selenium.common.exceptions.NoSuchElementException:
            print("[ERROR]: Attempting to upload meeting code...")
            if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
            else: driver.implicitly_wait(6)

time.sleep(7) # Ensure that the browser fully loads the next part.

for i in range(6):
    try:
        WebDriverWait(driver, 6).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Join now')]")))

        time.sleep(2)
        turn_off_mic_action = ActionChains(driver)
        turn_off_mic_action.key_down(Keys.CONTROL).send_keys("d").key_up(Keys.CONTROL).perform();
        turn_off_camera_action = ActionChains(driver)
        turn_off_camera_action.key_down(Keys.CONTROL).send_keys("e").key_up(Keys.CONTROL).perform();
        print("Sucessfully found landmark...turned off camera and microphone.")
        break
    except selenium.common.exceptions.TimeoutException:
        try:
            WebDriverWait(driver, 6).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Ask to join')]")))

            time.sleep(2)
            turn_off_mic_action = ActionChains(driver)
            turn_off_mic_action.key_down(Keys.CONTROL).send_keys("d").key_up(Keys.CONTROL).perform();
            turn_off_camera_action = ActionChains(driver)
            turn_off_camera_action.key_down(Keys.CONTROL).send_keys("e").key_up(Keys.CONTROL).perform();
            print("Sucessfully found landmark...turned off camera and microphone.")
            break
        except selenium.common.exceptions.TimeoutException:
            print("[ERROR]: Attempting to find landmark...")
            if USE_FAILSAFE_PERCAUTIONS: time.sleep(6)
            else: driver.implicitly_wait(6)

try:
    join_button = WebDriverWait(driver, 36).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Join now')]")))
    driver.execute_script("arguments[0].click();", join_button)
except selenium.common.exceptions.TimeoutException:
    try:
        join_button = WebDriverWait(driver, 36).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(),'Ask to join')]")))
        driver.execute_script("arguments[0].click();", join_button)
    except selenium.common.exceptions.TimeoutException:
        print("Couldn't join Google Meet. Are you sure you have the right code?")

这篇关于自动加入Google Meeting会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆