From the course: Learning Python

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Parsing and processing HTML

Parsing and processing HTML - Python Tutorial

From the course: Learning Python

Parsing and processing HTML

- Python provides a built-in way for parsing structured data, such as HTML, as well as other kinds of data like we just saw previously with Jason. In this example, we're going to see how to create our own HTML parser based on the HTML parser class that Python provides. So let's go ahead and open HTML parsing underscore start, and you can see that what I've done here is I've already created my main function and I've got a variable called parser and I'm instantiating a my HTML parser class and I've created the starting point for that class up here which we will fill out with our logic. I've also imported the HTML parser class that we need from the HTML parser module and I'm creating a subclass of the existing HTML parser class that we've imported. And we'll come back to this in a moment. So in the main function, I already have the code needed to open an HTML file and parse it. Now I could have just used URL lib to open a…

Contents