Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # GeradorDeHtml.py
- #
- # Copyright 2021 Elizeu Barbosa Abreu <elizeubcorreios@gmail.com>
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- #
- #
- # ESTE CODIGO PYTHON GERA PAGINAS HTML SIMPLES
- # Escolhe o Diretório onde vai salvar o arquivo
- diretorio = str(input('Entre com o diretorio do arquivo: '))
- # Escolhe o nome do arquivo. Ex index.html
- nomedoarquivo = str(input('Entre com o nome do aquivo html: '))
- # Cria o caminho do arquivo completo. Ex.: C:/Meus Documentos/index.html
- url = diretorio + '/' + nomedoarquivo + '.html'
- # Abre um arquivo existente para substituição do texto ou cria um novo arquivo para edicao
- f = open(url, 'w')
- # Pede o Título do texto
- titulo = str(input('Entre com o título da página: '))
- # Pede o conteúdo do Texto
- conteudo = str(input('Entre com o conteudo do aquivo html: '))
- # Codigo com as tags cabeçalho html até o título
- inicio = '''
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>'''
- # Código html que vem depois do título até a inserção do conteúdo
- postitulo = '''</title>
- <meta http-equiv="content-type" content="text/html;charset=utf-8" />
- <meta name="generator" content="Geany 1.33" />
- </head>
- <body>
- <div>
- '''
- # Restante do código html após o conteúdo
- final = '''
- </div>
- </body>
- </html>
- '''
- f.write(inicio + titulo + postitulo + conteudo + final)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement