Skip to content

Instantly share code, notes, and snippets.

Created August 7, 2017 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dado3212/d65ae292404e35546681fdfa067c42dd to your computer and use it in GitHub Desktop.
Save dado3212/d65ae292404e35546681fdfa067c42dd to your computer and use it in GitHub Desktop.
Uses Selenium to delete every topic in a Google Group (rate of around 2k/hour deletions)
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import as ui
from import By
from import expected_conditions as EC
credentials = {
# login credentials for google group
'username': '<username>',
'password': '<password>',
# name of the group
'group_name': '<group_name>',
def delete_everything(driver):
# Open the main window
wait = ui.WebDriverWait(driver, 10)
driver.get('' + credentials['group_name'] + '&hl=en&service=groups2')
# Login
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[type="email"]')))
username = driver.find_element_by_css_selector('input[type="email"]')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[type="password"]')))
password = driver.find_element_by_css_selector('input[type="password"]')
# =============
# =============
deleted = True
while (deleted):
deleted = False
# Choose a topic
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div[role="listitem"]')))
topic = driver.find_element_by_css_selector('div[role="listitem"]')
if topic:
# Open actions
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div[data-title="Actions"]')))
actions_button = driver.find_element_by_css_selector('div[data-title="Actions"]')
# Choose delete
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#ma_DELETE_TOPICS')))
delete_option = driver.find_element_by_css_selector('#ma_DELETE_TOPICS')
# Choose 'Other' option
wait.until(EC.element_to_be_clickable((By.XPATH, "//label[contains(text(), 'Other')]")))
other_option = driver.find_element_by_xpath("//label[contains(text(), 'Other')]")
other_option_parent = other_option.find_element_by_xpath("..")
radio = other_option_parent.find_element_by_css_selector('span[role="radio"]')
# Submit delete request
deleted = True
finished = False
while not finished:
driver = webdriver.Chrome('./chromedriver') # Download from
finished = True
except Exception as e:
print e
finished = False
time.sleep(5) # Wait 5 seconds, and go again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment