Mudanças entre as edições de "Python:Request"
Ir para navegação
Ir para pesquisar
| Linha 8: | Linha 8: | ||
from urllib.request import urlopen | from urllib.request import urlopen | ||
html = urlopen("http://www.pagina_exemplo.com") | html = urlopen("http://www.pagina_exemplo.com") | ||
| + | |||
| + | == BeaultifulSoap == | ||
| + | Métodos de coleta | ||
| + | [[https://www.crummy.com/software/BeautifulSoup/bs4/doc/#method-names]] | ||
| + | |||
| + | === Recupera todos os href da pagina == | ||
| + | ############################## Carrega arquivo para memória | ||
| + | html = open('dataset/result/site-01.html') | ||
| + | bs = BeautifulSoup(html, 'html.parser') | ||
| + | ############################## Busca todos os A HREF | ||
| + | curriculos = [] | ||
| + | for link in bs.find_all('a'): | ||
| + | js = link.get('href') | ||
| + | curriculos.append(js) | ||
Edição das 10h15min de 29 de janeiro de 2023
Request
Install Requests
pip install requests pip install beautifulsoup4 pip install selenium
Carrega uma pagina
from urllib.request import urlopen
html = urlopen("http://www.pagina_exemplo.com")
BeaultifulSoap
Métodos de coleta
[[1]]
= Recupera todos os href da pagina
############################## Carrega arquivo para memória
html = open('dataset/result/site-01.html')
bs = BeautifulSoup(html, 'html.parser')
############################## Busca todos os A HREF
curriculos = []
for link in bs.find_all('a'):
js = link.get('href')
curriculos.append(js)