Beautiful 疑问小记

一、获取id和class的text()

  html = urlopen(real_url)

  bsObj = BeautifulSoup(html)
  
h1 = bsObj.h1.get_text()
  content = bsObj.find(id="mw-content-text").findAll("p")[0]

  class_text = bsObj.find(class_="class_name")

二、读取属性

  直接类似于JQUery 用.attrs["attribute_name"]

原文地址:https://www.cnblogs.com/mxh1099/p/5679445.html