course content

Course Content

Web Scraping with Python

Applying String MethodsApplying String Methods

What can you do with the read page? It is a string, so that you can use/apply any string method. For instance, you can use the .find() method that returns the index of the first occurrence of a certain element. For example, find the page title by finding the first opening and closing tags indexes. Also, we will consider the length of the closing tag.

As you can see in the example above, two variables start and end were created. Variable start contains the index of the first element of the first occurence of the <title> element. The finish variable contains the last index of the closing </title> tag. The .find() method itself returned the first index of closing tag, so we added length of the tag to have the index of the last element.

Section 1.

Chapter 10