Skip to content

Instantly share code, notes, and snippets.

@jrial
jrial / html_to_text.py
Last active April 18, 2018 13:04 — forked from racitup/html_to_text.py
Extract text from html in python using BeautifulSoup4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from bs4 import BeautifulSoup, NavigableString, Tag
def html_to_text(html):
"Creates a formatted text email message as a string from a rendered html template (page)"
soup = BeautifulSoup(html, 'html.parser')
# Ignore anything in head
@jrial
jrial / gist:165d8d54e80f6f91ab5577072e8dcdc3
Created March 22, 2017 12:30 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>