Created
April 30, 2020 01:07
-
-
Save rtancman/6019774e2c4ddd65159688fc66fc4146 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.request import urlopen | |
from urllib.error import HTTPError | |
from bs4 import BeautifulSoup | |
def getDescription(url): | |
try: | |
html = urlopen(url) | |
except HTTPError as e: | |
return None | |
try: | |
content = BeautifulSoup(html.read(), "html.parser") | |
description = content.select('div.row.row-space p:first-child') | |
except AttributeError as e: | |
return None | |
return description | |
def getDevelopers(url): | |
try: | |
html = urlopen(url) | |
except HTTPError as e: | |
return None | |
try: | |
content = BeautifulSoup(html.read(), "html.parser") | |
developers = content.select('div.row.comunity--members div ul:first-child') | |
except AttributeError as e: | |
return None | |
return developers | |
if __name__ == '__main__': | |
url = "https://blumenau.sc.python.org.br/comunidade" | |
description = getDescription(url) | |
developers = getDevelopers(url) | |
if developers == None or description == None: | |
print("Descrição não encontrada") | |
else: | |
print(description) | |
for d in developers: | |
teste = d.text | |
print(teste) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment