Learn Beautiful Soup
Parse, search and edit HTML and XML in Python, even when it's badly broken
Beautiful Soup (the bs4 package) parses HTML and XML into a tree of Python objects that you can search with find_all or CSS selectors, navigate and modify. It's the most popular tool for web scraping and for cleaning or transforming HTML, and it copes gracefully with the malformed markup found on real websites.
Before you start
How deep do you want to go?
1. EssentialsRead and write simple code, do the everyday basics
2. PracticalUse it productively at work, with the usual idioms
3. AdvancedThe less common features, performance and trade-offs
4. ExpertInternals and the edge cases experts know