【发布时间】:2020-07-06 23:28:34
【问题描述】:
我正在使用 python 的 BeautifulSoup 库来抓取文本,但我想抓取所有包含类名的元素。
因此,如果多个元素具有“ProductCard”字样,但每个元素前面的字母排列略有不同(例如“ProductCard-HbksbD”、“ProductCard-UfbraH”),有没有办法获得所有这些?
for item in soup.find_all('a', {'class': 'ProductCard'}):
print(item)
谢谢
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/questions/52842778/…
-
@vmouffron 是的!非常感谢!!
标签: python html class web-scraping beautifulsoup