forked from NBO2001/Automatizador-de-rotina
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrapping_boxs.py
147 lines (110 loc) · 4.74 KB
/
scrapping_boxs.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
143
144
145
146
147
from time import sleep
from utils import element_is_load, get_table, add_values_in_dictionary,trim
def scrapping_b(instance, datas):
base_url = instance.get_urlBase()
dic_values = dict()
lista_values = list()
for data in datas:
link = datas[data]['link']
instance.driver.get(f'{base_url}{link}')
if not element_is_load(instance, "//mat-card/div/div[1]/mat-form-field[3]/div/div[1]/div/mat-select/div/div[1]/span/span"):
return False
input_galpao = instance.driver.find_element_by_xpath("//mat-card/div/div[1]/mat-form-field[1]/div/div[1]/div/input")
local = input_galpao.get_attribute("value")
input_galpao = instance.driver.find_element_by_xpath("//mat-card/div/div[1]/mat-form-field[2]/div/div[1]/div/mat-select/div/div[1]/span/span")
galpao = input_galpao.get_attribute("innerHTML")
input_prateleira = instance.driver.find_element_by_xpath("//mat-card/div/div[1]/mat-form-field[3]/div/div[1]/div/mat-select/div/div[1]/span/span")
prateleira = input_prateleira.get_attribute("innerHTML")
dic_values = {
'index': data,
'link': link,
'type': datas[data]['type'],
'local': local,
'galpao': galpao,
'prateleira':prateleira,
'client': datas[data]['client']
}
sleep(2)
table_conteinner = instance.driver.find_element_by_xpath("//app-pack-itens/mat-card/div/div[2]/mat-table")
table = get_table(table_conteinner)
dats = add_values_in_dictionary(table)
dic_values['boxs'] = dats
lista_values.append(dic_values.copy())
instance.driver.get(f'{base_url}#/modules/home')
return lista_values
def scrapping_folders_inf(instance, link):
sleep(2)
values_data = dict()
try:
in_codigo = instance.driver.find_element_by_xpath("//mat-card/div/div[2]/mat-form-field[1]/div/div[1]/div/input")
code = in_codigo.get_attribute("value")
except:
code = "S/N"
try:
in_type = instance.driver.find_element_by_xpath("//mat-card/div/div[2]/mat-form-field[2]/div/div[1]/div/mat-select/div/div[1]/span/span")
type = in_type.get_attribute("innerHTML")
except:
type = "S/N"
try:
in_client = instance.driver.find_element_by_xpath("//mat-card/div/div[2]/mat-form-field[3]/div/div[1]/div/mat-select/div/div[1]/span/span")
client = in_client.get_attribute("innerHTML")
except:
client = "S/N"
try:
in_depart = instance.driver.find_element_by_xpath("//mat-card/div/div[2]/mat-form-field[4]/div/div[1]/div/mat-select/div/div[1]/span/span")
depart = in_depart.get_attribute("innerHTML")
except:
depart = "S/N"
try:
in_subject = instance.driver.find_element_by_xpath("//mat-card/div/div[3]/mat-form-field[1]/div/div[1]/div/input")
subject = in_subject.get_attribute("value")
except:
subject = "S/N"
try:
in_indx = instance.driver.find_element_by_xpath("//mat-card/div/div[4]/mat-form-field[1]/div/div[1]/div/input")
indx = in_indx.get_attribute("value")
except:
indx = "S/N"
try:
in_date = instance.driver.find_element_by_xpath("//mat-card/div/div[4]/mat-form-field[2]/div/div[1]/div/input")
date = in_date.get_attribute("value")
except:
date = "S/N"
try:
in_date_end = instance.driver.find_element_by_xpath("//mat-card/div/div[4]/mat-form-field[2]/div/div[1]/div/input")
date_end = in_date_end.get_attribute("value")
except:
date_end = "S/N"
try:
in_obs = instance.driver.find_element_by_xpath("//mat-card/div/div[5]/mat-form-field[1]/div/div[1]/div/input")
obs = in_obs.get_attribute("value")
except:
obs = "S/N"
values_data = {
"index": trim(code),
"type": trim(type),
"client": trim(client),
"department": trim(depart),
"subject": trim(subject),
"indexing": trim(indx),
"date_start": trim(date),
"date_end": trim(date_end),
"obs": trim(obs),
"link": trim(link)
}
return values_data
def scan_items_in_sys(instance):
list_items = list()
element_is_load(instance, "//mat-table/mat-row[1]", 10)
table_element = instance.driver.find_element_by_xpath("//mat-table")
table = get_table(table_element)
for tab in table:
rows = tab.find_all("mat-cell")
list_items.append({
"upload": trim(rows[0].text),
"link": trim(rows[1].a['href']),
"name": trim(rows[1].text),
"subject": trim(rows[2].text),
"describe": trim(rows[3].text)
})
return list_items