-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
143 lines (100 loc) · 4.07 KB
/
setup.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# -*- encoding: utf-8 -*-
import requests
import selenium.webdriver.support.ui as ui
from time import sleep
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
import json
def doingGroup(groupY, urlX):
#Carregar cookies para manter a conta logada e evitar bloqueio
option = Options()
option.add_argument("user-data-dir=C:\\Users\\gusta\\AppData\\Local\\Google\\Chrome\\User Data\\Default ")
driver = webdriver.Chrome(options=option)
driver.get("https://www.google.com")
driver.get(urlX)
sleep(5)
openMenu(driver)
findMessages(groupY, driver)
print(groupY)
sleep(2)
driver.quit()
print("Processo Finalizado.")
def openMenu(driverX):
menu = driverX.find_element_by_xpath("//*[@id='ng-app']/body/div[1]/div[1]/div/div/div[2]/div/div[1]")
menu.click()
#Iniciar o elemento "encaminhar"
element = driverX.find_element_by_xpath("//*[@id='ng-app']/body/div[1]/div[1]/div/div/div[2]/div/div[1]/ul/li[1]/a")
element.click()
sleep(1)
def findMessages(groupX, driverY):
f = open(groupX, 'r')
p = f.readline()
f.close()
all_div = driverY.find_elements_by_xpath("//div[@class='im_message_outer_wrap hasselect']")
for x in range(0,len(all_div)):
idMessage = all_div[x].get_attribute('data-msg-id')
if int(idMessage) > int(p.strip()):
all_div[x].click()
fp = open(groupX, 'w')
fp.writelines(idMessage)
def newIDGroups():
answerX = input("Qual grupo deseja configurar? (0 = Nenhum | 1 = Grupo 1 | 2 = Grupo 2 | 3 = Grupo 3 | 4 = Grupo 4 | 5 = Grupo 5 | 9 = Todos os grupos\n")
if answerX == '0':
return False
if answerX != '0':
filterGroups(answerX)
again = input("Deseja configurar outro grupo? (0 = Não | Qualquer outro caractere = Sim\n")
if again != '0':
newIDGroups()
def filterGroups(answer1):
print(answer1)
if answer1 == '9':
url1 = input("Insira URL do Grupo 1: ")
doingGroup("group1.js", url1)
url2 = input("Insira URL do Grupo 2: ")
doingGroup("group2.js", url2)
url3 = input("Insira URL do Grupo 3: ")
doingGroup("group3.js", url3)
url4 = input("Insira URL do Grupo 4: ")
doingGroup("group4.js", url4)
url5 = input("Insira URL do Grupo 5: ")
doingGroup("group5.js", url5)
if answer1 == '1':
url1 = input("Insira URL do Grupo 1: ")
doingGroup("group1.js", url1)
return 0
if answer1 == '2':
url2 = input("Insira URL do Grupo 2: ")
doingGroup("group2.js", url2)
return 0
if answer1 == '3':
url3 = input("Insira URL do Grupo 3: ")
doingGroup("group3.js", url3)
return 0
if answer1 == '4':
url4 = input("Insira URL do Grupo 4: ")
doingGroup("group4.js", url4)
return 0
if answer1 == '5':
url5 = input("Insira URL do Grupo 5: ")
doingGroup("group5.js", url5)
return 0
newAccount = input("Deseja adicionar uma nova conta? (0 = Não | Qualquer outro caractere = Sim )\n")
if newAccount != '0':
option = Options()
option.add_argument("user-data-dir=C:\\Users\\gusta\\AppData\\Local\\Google\\Chrome\\User Data\\Default ")
driver = webdriver.Chrome(options=option)
driver.get("https://www.google.com")
driver.get("https://web.telegram.org")
print("Por favor, entre manualmente a sua conta no Browser que foi aberto\n")
print("Depois de 30 segundos, será possível continuar\n")
sleep(30)
input("Ao terminar, insira qualquer caractere para continuar...\n")
newID = input("Deseja configurar novos grupos? (0 = Não | Qualquer outro caractere = Sim )\n")
if newID != '0':
newIDGroups()