Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Applying String Methods | Getting Acquainted with HTML
Web Scraping with Python

Applying String MethodsApplying String Methods

What can you do with the read page? It's a string, so you can utilize any string method. For instance, you can use the .find() method, which returns the index of the first occurrence of a specific element. For example, you can locate the page title by identifying the indexes of the first opening and closing tags. We'll also take into account the length of the closing tag.

As demonstrated in the example above, two variables, start and finish, were created. The start variable contains the index of the first element within the initial occurrence of the <title> element. Meanwhile, the finish variable holds the index of the character immediately following the closing </title> tag. The .find() method itself provided the initial index of the closing tag, so we added the length of the tag to obtain the index of the last element.

Note

List slicing excludes the last element, which is why we find the next character after the closing tag.

Все було зрозуміло?

Секція 1. Розділ 10
course content

Зміст курсу

Web Scraping with Python

Applying String MethodsApplying String Methods

What can you do with the read page? It's a string, so you can utilize any string method. For instance, you can use the .find() method, which returns the index of the first occurrence of a specific element. For example, you can locate the page title by identifying the indexes of the first opening and closing tags. We'll also take into account the length of the closing tag.

As demonstrated in the example above, two variables, start and finish, were created. The start variable contains the index of the first element within the initial occurrence of the <title> element. Meanwhile, the finish variable holds the index of the character immediately following the closing </title> tag. The .find() method itself provided the initial index of the closing tag, so we added the length of the tag to obtain the index of the last element.

Note

List slicing excludes the last element, which is why we find the next character after the closing tag.

Все було зрозуміло?

Секція 1. Розділ 10
some-alt