在我的工作中,我们使用的是我们创建的标签.其中一个标签叫做can-edit,它在代码中看起来像这样(例如):
<h1 can-edit="banner top text" class="mainText">some text</h1>
<h2 can-edit="banner bottom text" class="bottomText">some text</h2>
Run Code Online (Sandbox Code Playgroud)
它可以在任何标签内(img,p,h1,h2,div ......).
我希望得到的是页面中的所有可编辑标签,例如上面的HTML:
['banner top text', 'banner bottom text']
Run Code Online (Sandbox Code Playgroud)
我试过了
soup = BeautifulSoup(html, "html.parser")
can_edits = soup.find_all("can-edit")
Run Code Online (Sandbox Code Playgroud)
但它找不到任何东西.