作者atb (Transition)
看板Python
標題[問題] BeautifulSoup如何排除特定class
時間Tue Feb 28 20:01:19 2023
各位好,最近使用beautifulsoup在爬html時遇到一個問題
<table class="alpha beta">
</table>
<table class="alpha">
</table>
若使用 beautifulsoup.select('table.alpha')會選到兩個table
但我不希望class="beta"的table被選到,請問要如何修正呢? 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.142.61.194 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1677585683.A.271.html
→ Hsins: bs.select("table[class='alpha']") 02/28 22:17
→ lycantrope: "table[class='alpha']" 02/28 23:14
推 OnoderaHaru: s.select('.alpha:not(.beta)') 03/01 07:28
→ tzouandy2818: Google搜尋CSS選擇器 03/02 06:57
→ atb: 謝謝大家的協助,問題解決了,可以正確選取了 03/04 19:57
→ g919233: css-selector/ 03/11 06:34