HTML email and Python a journey - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

HTML email and Python a journey

Description:

HTML email and Python a journey. Dave Cranwell. HTML email and Python a ... Pythonic binding of libxml2 (C) up to 20 X faster than Beautiful Soup at parsing ... – PowerPoint PPT presentation

Number of Views:97
Avg rating:3.0/5.0
Slides: 13
Provided by: davecr5
Category:

less

Transcript and Presenter's Notes

Title: HTML email and Python a journey


1
HTML email and Python - a journey
  • Dave Cranwell.

2
Clients
3
CampaignMonitor.com/css
4
Clients
Booo
No ltstylegt No ltlinkgt
Hiss!
complete crap
5
Python to the rescue!
LULZ
6
Libraries
Python Package Index http//pypi.python.org
  • Beautiful Soup
  • Element Soup
  • Element Tree
  • lXML
  • Minidom
  • PyQuery
  • CSS Utils

7
Libraries
  • Beautiful Soup
  • Element Soup
  • Element Tree
  • lXML
  • Minidom
  • PyQuery
  • CSS Utils

8
lXML
  • Pythonic binding of libxml2 (C)
  • up to 20 X faster than Beautiful Soup at parsing
  • Includes CSSSelect, which converts a CSS 2.1
    selector into an Xpath
  • http//blog.ianbicking.org/2008/03/30/python-ht
    ml-parser-performance/

9
Introducing...
10
Whats happening?
  • lXML parses HTML and converts to an eTree
  • CSSUtils parses CSS rules into objects
  • Loop over CSS rules converting each to XPath with
    CSSSelect
  • Create CSSStyleDeclaration for each element
    affected by a CSS rule
  • Contains details of the tag as well as the
    combined styles applied
  • Loop over eTree and serialised matching
    CSSStyleDeclarations into the style attribute.

11
No Google App engine, sadly
  • No C libs x
  • Pure Python only x
  • (and java)
  • Piss easy to setup P
  • Bloody cool P

12
FIN
  • Dave Cranwell.
  • david_at_torchbox.com
Write a Comment
User Comments (0)
About PowerShow.com