Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- class G1(object):
- def __init__(self):
- self._domain = "https://g1.globo.com/"
- self.soup = None
- self.get_content()
- def get_content(self):
- try:
- self.soup = BeautifulSoup(requests.get(self._domain).text, 'lxml')
- except Exception as e:
- print("Exceção levantada {}".format(e))
- def get_news(self):
- for news_title in (news.text for news in self.soup.findAll('a', class_='feed-post-link')):
- print(news_title, end='\n\n')
- globo = G1()
- globo.get_news()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement