我想从下面的html代码中提取strong和sup标记的值:
[<li class="price-current"><span class="price-current-label"></span>$<strong>299</strong><sup>.99</sup> <a class="price-current-num" href="https://www.newegg.com/xfx-radeon-rx-5600-xt-rx-56xt6df46/p/N82E16814150835?Item=N82E16814150835&buyingoptions=New">(4 Offers)</a><span class="price-current-range"><abbr title="to">–</abbr></span></li>]
尝试:
运行此操作后,
output
列表将从data3
的所有元素中获得第一个strong
和sup
元素如果希望将文本放在标记中,可以在
find
调用之后使用.content
或.get_text()
。像soup.find("strong").get_text()
有关靓汤的更多帮助,请参见https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find
相关问题 更多 >
编程相关推荐