Skip to content

Instantly share code, notes, and snippets.

@rtancman
Created April 30, 2020 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtancman/6019774e2c4ddd65159688fc66fc4146 to your computer and use it in GitHub Desktop.
Save rtancman/6019774e2c4ddd65159688fc66fc4146 to your computer and use it in GitHub Desktop.
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