from bs4 import BeautifulSoup
import requests
url = 'http://g1.com.br/'
header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/51.0.2704.103 Safari/537.36'}
req = requests.get(url,headers= header)
html = req.text
soup = BeautifulSoup(html,'html.parser')
colecao = soup.find_all(class_="feed-post-body-title gui-text-title gui-color-primary") #div eh texto
for item in colecao:
print(item.get_text())
The above code should get the top news on the link site. that is with the tag:
<p class="feed-post-body-title gui-text-title gui-color-primary gui-color-hover">
Unfortunately, it is doing nothing and does not return an error ("Process finished with exit code 0"). can anybody help me? I tested with python 2.7