-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshare_sheet.py
More file actions
87 lines (62 loc) · 2.73 KB
/
Copy pathshare_sheet.py
File metadata and controls
87 lines (62 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from selenium import webdriver
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
from selenium.webdriver.chrome.options import Options
import time
import gspread
from oauth2client.service_account import ServiceAccountCredentials
mail_to_share = "closedopen@bet-sagur-patuah.iam.gserviceaccount.com"
url_sheet = "https://docs.google.com/spreadsheets/d/1JTQ-iapUk52L4PPfyiJ91m471Ox4KpfRIyyTRo9O1rg/edit#gid=24955804"
chrome_options = Options()
chrome_options.add_argument('--user-data-dir=./User_Data')
# chrome_options.add_argument("--headless")
# chrome_options.add_argument("--disable-gpu")
# chrome_options.add_argument("--remote-debugging-port=9222")
# chrome_options.add_argument("--disable-dev-shm-usage")
print("finish initial")
driver = webdriver.Chrome(options=chrome_options)
print("fuck margolis")
WebDriverWait(driver, 10)
driver.get(url_sheet)
# driver.maximize_window()
time.sleep(5)
print(driver.page_source)
print("ok")
share_box = driver.find_element_by_xpath('//*[@id="docs-titlebar-share-client-button"]/div').click()
time.sleep(4)
print("ok")
driver.switch_to.frame(7)
time.sleep(2)
print("iframe")
driver.find_element_by_xpath('/html/body/div[5]/div[3]/div/div[4]/div/div[1]/div[1]/div[1]/textarea').send_keys(mail_to_share, Keys.ENTER)
time.sleep(1)
#uncheck the email
driver.find_element_by_xpath('/html/body/div[5]/div[3]/div/div[5]/div[1]/div[2]/span').click()
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[5]/div[3]/div/div[7]/div[1]/div').click()
time.sleep(3)
driver.find_element_by_xpath('/html/body/div[8]/div[3]/button[1]').click()
driver.switch_to.default_content()
"""
# initial the google sheet
# defines the scope
SCOPE_Server = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
# creates credentials using the scope and the content of closedOpen.json file
creds = ServiceAccountCredentials.from_json_keyfile_name('closedOpen.json', SCOPE_Server)
# creates a gspread client authorizing it using the credentials
client = gspread.authorize(creds)
# get the names of all the people
url_all_people = "https://docs.google.com/spreadsheets/d/1yKEb0mTdTSJGFaSUV6xoNRYwcIzA90y4WJqlKgrZua8/edit#gid=1866447610"
spread_sheet_all_people = client.open_by_url(url_all_people).worksheets()[0]
temp_all_people = spread_sheet_all_people.col_values(1)[1:]
all_people = []
for name in temp_all_people:
all_people.append(name.split(" -")[0])
print(all_people)
# get the names of all the people that answer the form
spread_sheet = client.open_by_url(url_sheet).worksheets()[0]
ans_people = spread_sheet.col_values(2)[1:]
print(ans_people)
"""