Programas Python
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
# Criado por: profa. Divani Barbosa Gavinier | |
# Curriculo Lattes: http://lattes.cnpq.br/8503400830635447 | |
# divanibarbosa@gmail.com | |
#Programa 1 | |
#imprimindo pagina na tela | |
import urllib.request | |
pagina=urllib.request.urlopen('http://beans.itcarlow.ie/prices.html') | |
texto=pagina.read().decode('utf8') | |
print (texto) | |
#Programa 2 | |
#imprimindo somente o preco na tela | |
import urllib.request | |
pagina = urllib.request.urlopen('http://beans.itcarlow.ie/prices.html') | |
texto = pagina.read().decode('utf8') | |
onde = texto.find('$') | |
inicio = onde + 1 | |
fim = inicio + 4 | |
preco = texto[inicio:fim] | |
print ("Somente o preco = " , preco) | |
#Programa 3 | |
# buscando o preco | |
import urllib.request | |
pagina = urllib.request.urlopen('http://beans.itcarlow.ie/prices.html') | |
texto = pagina.read().decode('utf8') | |
onde = texto.find('$') | |
inicio = onde + 1 | |
fim = inicio + 4 | |
preco = texto[inicio:fim] | |
# criando pagina html | |
arquivo = open('MinhaPagina.html','w', encoding='utf-8') | |
# encoding utf-8 é ara aparecer os acentos na página | |
arquivo.write('''<!DOCTYPE html> <html lang="pt-BR"> | |
<head><meta charset="utf-8"> <title> Valores do café </title></head> | |
<body> Agora o café esta custando: ''') | |
arquivo.write(preco) | |
arquivo.write('''</body></html>''') | |
arquivo.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obrigada professora.