I want a regular expression to extract the title from a HTML page. Currently I have this: Is there a regular expression to extract just the contents of <title> so I don’t have to remove the tags? Answer Use ( ) in regexp and group(1) in python to retrieve the captured string (re.search will return None if it doesn’t find
Tag: html
Send HTML emails with Python
How to send HTML content in email using Python? I can send simple texts. Answer From Python v2.7.14 documentation – 18.1.11. email: Examples: Here’s an example of how to create an HTML message with an alternative plain text version:
Validate (X)HTML in Python
What’s the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I’d like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. Answer XHTML is easy, use lxml. HTML is harder, since there’s traditionally not been as much interest