Skip to content

Instantly share code, notes, and snippets.

@thiagodeschamps
Created August 19, 2018 23:49
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 thiagodeschamps/74419130406347679ae316a9f2db6760 to your computer and use it in GitHub Desktop.
Save thiagodeschamps/74419130406347679ae316a9f2db6760 to your computer and use it in GitHub Desktop.
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