[Python] Beautiful Soup 隨手筆記

柏朗棕 Mr.Brown
Mr.Brown柏朗棕
Published in
1 min readApr 18, 2019

find() 回傳第一個找到的區塊

find_all() 則是回傳一個 list

  • soup.find_all("標籤類型", class_ = "class名稱", attrs={"自定義標籤的識別標記": "自定義標籤的值"})
  • soup.find_all("div", class_="image-Items", attrs={"data-v-7f29b543": " "})
  • 可以利用 for X in soup.find_all 的方式依序倒出找到的內容
  • 如果想要指定到出特定index的內容則須使用.content,例如: XXXX_tag.contents[0]、XXXX_tag.contents[1]、XXXX_tag.contents[2]
  • XXXX_tag.標籤類型.contents[0],例如: XXXX_ttag.div.contents[0]

資料參考: https://ithelp.ithome.com.tw/articles/10186119

--

--