Created
August 19, 2018 23:49
-
-
Save thiagodeschamps/74419130406347679ae316a9f2db6760 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
import requests | |
from bs4 import BeautifulSoup | |
estado = str(input('Digite a sigla do seu estado(Ex: SP): ')).upper().strip() | |
cidade = str(input('Digite o nome de sua cidade(Ex: Jacarei): ')).lower().strip().replace(' ', '') | |
url = f'http://www.tempoagora.com.br/previsao-do-tempo/{estado}/{cidade}' | |
response = requests.get(url).text | |
cont = BeautifulSoup(response, 'lxml') | |
temp = cont.find('li', class_ = 'dsp-cell degree').text.strip() | |
print('\n') | |
print('-='*20) | |
print(f'A temperatura atual de {cidade.capitalize()}/{estado} é: {temp}°C') | |
print('-='*20) | |
print('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment