2019年2月4日 星期一

BeautifulSoup 中 find_all contents children descendants select 的使用時機

初學者常看到的網路上文件或程式碼通常是這樣取得一個節點

tr.td.ul.li.table.tbody.tr

但是有一行很不起眼的註解出現在文件中:

Using a tag name as an attribute will give you only the first tag by that name:

所以如果你要存取的是同層級的第二個 tr 或 td 呢? 嘿嘿嘿…