-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolverBlog.py
40 lines (31 loc) · 1.19 KB
/
solverBlog.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
from selenium import webdriver
from selenium.webdriver.common.by import By
import re
import time
def visita(enlaces, pattern, count, visitadas):
try:
enlaces = driver.find_elements(By.CLASS_NAME, 'card-title')
for i in enlaces:
enlace = i.find_element(By.CSS_SELECTOR,'a').get_attribute('href')
if enlace not in visitadas and'#' not in enlace and enlace.startswith('http://ctf-vulnerable.numa.host:8040/notice'):
print("enlace -> " + enlace)
driver.get(enlace)
visitadas.add(enlace)
text = driver.find_element(By.CLASS_NAME, 'article-post').text
results = re.findall(pattern, text)
for match in results:
count = count + 1
print(match)
print(count)
else:
print("Ya visitado")
return count + visita(enlaces, pattern, count, visitadas)
except Exception:
pass
driver = webdriver.Chrome()
driver.get("http://ctf-vulnerable.numa.host:8040/")
pattern = "URJC"
count = 0
visitadas = set()
enlaces = []
print(visita(enlaces, pattern, count, visitadas))