Python crawler entry 9: BeautifulSoup quickly find HTML content

☞ ░Go to LaoYuanPython blog https://blog.csdn.net/LaoYuanPython

I. Introduction

In the previous section, we introduced the main attributes of the BeautifulSoup object. Through these attributes, you can access tags and content, but this method can only access the first object that meets the conditions, or you need to traverse to access the object. In some cases, you cannot specify it. Features quickly locate tags and content. This section will introduce how to quickly locate tags and content using the relevant methods provided by BeautifulSoup. This section continues to reuse the HTML file and object definition code in the previous section.

The content of the c:\temp\s1.html file processed in the case of this section is as follows:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<style type="text/css">	.textline{color:blue;}</style>
<link href="https://blog.csdn.net/LaoYuanPython/article/details/95360624" rel="canonical"/>
<title>BeautifulSoups使用方法 - 老猿Python - CSDN博客 </title></head>
<body> 	
  <h1>老猿Python</h1>
	<div><p class="te

Guess you like

Origin blog.csdn.net/LaoYuanPython/article/details/113704229