Last active
October 28, 2020 21:09
-
-
Save marcelo-reis/0e72f63eba11beb31a8b688a7942c39d to your computer and use it in GitHub Desktop.
Python - A great way to start!
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
URL = 'https://pt.wikipedia.org/wiki/Programa_Ol%C3%A1_Mundo' | |
hw = '' | |
import urllib.request | |
try: | |
texto = urllib.request.urlopen(URL).read().decode('utf-8') | |
onde = texto.find('<title>') | |
except urllib.error.HTTPError: | |
print('Endereço Inválido') | |
except urllib.error.URLError: | |
print('Sem conexão') | |
else: | |
inicio = onde + 16 | |
fim = inicio + 9 | |
hwtxt = str(texto[inicio:fim]) | |
separa = hwtxt.split() | |
hw = ', '.join(separa) | |
if hw == '': | |
hw = 'Olá, Mundo (Modo Offline)' | |
print(f'{hw}!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Varre a página 'Programa Olá Mundo' da Wikipedia e exibe na tela a mensagem 'Ola Mundo!'
Browse the 'Hello World Program' page on Wikipedia and display the message 'Hello World!'
Varle la página 'Programa Hola Mundo' de Wikipedia y muestra en pantalla el mensaje 'Ola Mundo!'