Python 爬虫 —— BeautifulSoup

from bs4 import BeautifulSoup
            % 首字母大写,显然这是一个类

1. BeautifulSoup 类

HTML 解析类(parser)

r = requests.get(...)
soup = BeautifulSoup(r.text, 'html.parser')

2. 查找和定位方法

Learn Beautiful Soup(3)——使用Beautiful Soup进行查找

  • find(),find_all()
  • find_parent(),find_parents()
  • find_next(),find_all_next()
  • find_next_sibling(),find_next_siblings()
  • find_previous_sibling(),find_previous_siblings()
  • find_previous(),find_all_previous()
原文地址:https://www.cnblogs.com/mtcnn/p/9422929.html