-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc_kvota.py
More file actions
163 lines (152 loc) · 7.41 KB
/
func_kvota.py
File metadata and controls
163 lines (152 loc) · 7.41 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from selenium import webdriver
from fake_useragent import UserAgent
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
links = {
"Инжек 121": "https://vstup.edbo.gov.ua/offer/1131496/",
"Инжек 122": "https://vstup.edbo.gov.ua/offer/1133097/",
"Хире 121": "https://vstup.edbo.gov.ua/offer/1212991/",
"Хире 122 ИИ": "https://vstup.edbo.gov.ua/offer/1197830/"
}
my_score = 169.644
for tag, link in links.items():
try:
useragent = UserAgent()
options = webdriver.FirefoxOptions()
options.set_preference("general.useragent.override", useragent.random)
driver = webdriver.Firefox(options=options)
driver.get(link)
wait = WebDriverWait(driver, 20)
try:
time.sleep(5)
button = driver.find_element(By.XPATH, ".//*[@id='requests-load']")
button.click()
time.sleep(5)
blocks = wait.until(
EC.presence_of_all_elements_located(
(
By.XPATH,
".//div[contains(@class, 'offer-request') and contains(@class, 'request-status-6')]",
)
)
)
except:
blocks = wait.until(
EC.presence_of_all_elements_located(
(
By.XPATH,
".//div[contains(@class, 'offer-request') and contains(@class, 'request-status-6')]",
)
)
)
amount_budget = 0 # Инициализируем счетчик
amount_contract = 0
amount_first_priority = 0
scores_first_priority = []
scores_second_priority = []
scores_third_priority = []
scores_forth_priority = []
scores_fifth_priority = []
for post in blocks:
time.sleep(0.2)
score_element = post.find_element(
By.XPATH, ".//div[contains(@class, 'offer-request-kv')]/div"
)
score = score_element.text
print(score)
try:
priority_contract_element = post.find_element(
By.XPATH,
".//div[contains(@class, 'offer-request-priority')]/div[contains(@class, 'offer-request-contract')]",
)
priority_contract = priority_contract_element.text
print(priority_contract)
except:
priority_element = post.find_element(
By.XPATH,
".//div[contains(@class, 'offer-request-priority')]/div[contains(@class, 'offer-request-other')]",
)
priority = priority_element.text
print(priority)
# try:
# kvota_element = post.find_element(
# By.XPATH, ".//div[contains(@class, 'offer-subjects')]/div[contains(@class, 'offer-subject indicator indicator-q')]/div[contains(@class, 'sn')]"
# )
# kvota = kvota_element.text
# except:
# print("Без квоты")
# title_list = ["2", "3", "4", "5"]
#
# if priority == "1":
# amount_first_priority += 1
# scores_first_priority.append(score)
# scores_list.append(score)
# elif priority in title_list:
# scores_list.append(score)
#
# amount_budget += 1 # Увеличиваем счетчик при успешном выводе значения
# print("Контрактник\n")
#
#
# def sort_list(list):
# list = [float(num.replace(",", ".")) for num in list]
# list = sorted(list)
# list.reverse()
# return list
#
#
# scores_list = sort_list(scores_list)
#
# scores_first_priority = sort_list(scores_first_priority)
#
#
# def result(tag, num_priority, amount_num_priority, scores_num_priority, scores_list):
# print(tag)
# print("----------------")
# print("Всего на бюджет:", amount_budget) # Выводим общее количество значений в конце
# print("----------------------------")
# print("Всего на контракт:", amount_contract)
# print("--------------------------------")
# print(f"Всего на бюджет с {num_priority} приоритетом:", amount_num_priority)
# print("---------------------------------------------------")
# print(f"Максимальный балл с {num_priority} приоритетом:", max(scores_num_priority))
# print("---------------------------------------------------")
# print(f"Минимальный балл с {num_priority} приоритетом:", min(scores_num_priority))
# print("---------------------------------------------------")
# print(f"Средний балл с {num_priority} приоритетом:", sum(scores_num_priority) / len(scores_num_priority))
# print("---------------------------------------------------")
#
# print(
# f"Количество людей с таким же баллом с {num_priority} приоритетом: {scores_num_priority.count(my_score)}"
# )
# print("---------------------------------------------------")
#
# print(
# f"Количество людей с таким же баллом в общем (без контрактников): {scores_list.count(my_score)}"
# )
# print("---------------------------------------------------")
#
# scores_num_priority.append(my_score)
# scores_num_priority = sorted(scores_num_priority)
# scores_num_priority.reverse()
# print(f"На каком я месте среди {num_priority} приоритетов:", scores_num_priority.index(my_score) + 1)
# print(scores_num_priority)
# print("---------------------------------------------------")
# scores_list.append(my_score)
# scores_list = sorted(scores_list)
# scores_list.reverse()
# print(
# "На каком я месте среди общего списка (без контрактников):",
# scores_list.index(my_score) + 1,
# )
# print(scores_list)
# print("---------------------------------------------------")
#
#
# result(tag, 1, amount_first_priority, scores_first_priority, scores_list)`
except Exception as e:
print("Произошла ошибка:", e)
finally:
driver.quit()