-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedital_scrap.py
80 lines (57 loc) · 1.53 KB
/
edital_scrap.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
#!/bin/python3
"""
enconding: utf-8
Feito por : Exodo Jaffar
Permitido o uso, compartilhamento e ediçao do codigo
Todos os direitos reservados
"""
from requests import get
from bs4 import BeautifulSoup as bs
BASE_URL = "http://selecao.ifms.edu.br/perfil/"
# Pega o conteudo HTML do sites
def get_site_content(site:str):
# Retorna o conteudo do site passado na funcao
return get(BASE_URL + site).content
# Separa os dados do sites
def get_tags_from_content(content_html:str):
# Retorna a Div que esta os editais
bs_parser = bs(content_html, "html.parser")
editais_tags = bs_parser.find('div',class_='well').find_all('div')
return editais_tags
# Pegas os dados dos editais
def get_data(tags_edital) -> list:
"""
{
name: str,
url: str,
des: str,
}
"""
edital_data = list()
for tag in tags_edital:
data = dict()
tag_a = tag.find('a')
data['name'] = tag_a.text
data['url'] = BASE_URL + tag_a.get('href')
data['des'] = tag.find('p').text
edital_data.append(data)
return edital_data
def get_editais(editais_sites:tuple) -> list:
editais_content = list()
editais = list()
editais_data = []
for edital_site in editais_sites:
content = get_site_content(edital_site)
editais_content.append(content)
for edital_content in editais_content:
tags = get_tags_from_content(edital_content )
editais.append(tags)
for edital in editais:
editais_data.append(get_data(edital))
return editais_data
def main():
editais = get_editais(('estudantes','outras'))
print(editais)
pass
if __name__ == '__main__':
main()