We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d97dd27 commit a418b98Copy full SHA for a418b98
03 - BeautifulSoup/news.py
@@ -0,0 +1,21 @@
1
+import requests
2
+from bs4 import BeautifulSoup
3
+
4
+response = requests.get('https://g1.globo.com/')
5
6
+content = response.content
7
8
+site = BeautifulSoup(content, 'html.parser')
9
10
+# HTML da notícia
11
+noticia = site.find('div', attrs={'class': 'feed-post-body'})
12
13
+# Título
14
+titulo = noticia.find('a', attrs={'class': 'feed-post-link'})
15
16
+print(titulo.text)
17
18
+# Subtítulo: div class="feed-post-body-resumo"
19
+subtitulo = noticia.find('div', attrs={'class': 'feed-post-body-resumo'})
20
21
+print(subtitulo.text)
0 commit comments