我想要做的是选择第二个跨度并抓住它的文本来打印它。下面是 HTML 代码和 BeautifulSoup 代码
#HTML code
<h1 id="productTitle">
<a href="https://www.example.com/product/">
<span id="productBrand">BRAND</span>
</a>
<span>PRODUCT TITLE </span>
</h1>
#BeautifulSoup code
for h1 in soup.find_all('h1', id="productTitle"):
productTitle = h1.find('span').text
print(productTitle)
LEATH
素胚勾勒不出你
相关分类