From the course: Python for Data Science and Machine Learning Essential Training Part 1

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

NavigableString objects

NavigableString objects

- [Instructor] Now that we've finished tag objects, let's start looking at the NavigatableString object. Before getting started here, I just want to check to make sure that our version of Python is comparable with the demonstration we're about to do. So this notebook was written for Python 3.10. Let's just check the version we are running here. So we'll say import sys, and then we'll print sys.version. And run this. Oops. This needs to be a new line here. Okay, run this. Okay, cool. So we have version 3.10, so we're good to go. Next, let's just go ahead and import BeautifulSoup. So to do that, we'll say from BS4 import BeautifulSoup. Run this. And now we have our BeautifulSoup library imported into our IPython environment. Now in this demonstration I'm going to show you how to work with NavigatableString objects. NavigatableString objects are used as containers for chunks of text that are stored inside of tag objects. So let's just go back to our example from a previous lecture with…

Contents