1

Python爬虫编程思想(56):Beautiful Soup方法选择器之find方法

 2 years ago
source link: https://blog.csdn.net/nokiaguy/article/details/120797031
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python爬虫编程思想(56):Beautiful Soup方法选择器之find方法

find方法与find_all方法有如下几点不同。

  1. find方法用于查询满足条件的第1个节点,而find_all方法用于查询所有满足条件的节点。
  2. find_all方法返回bs4.element.ResultSet对象,而find方法返回的是bs4.element.Tag对象。

find方法与find_all方法的参数和使用方法完全相同。

        下面的本例同时使用find_all方法和find方法根据相同的查询条件查询节点,并输出各自的查询结果。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK