[英]Why i'm getting an empty list when i try to use find_all function to searching by css with "class_" in Python 3.8 using bs4?
I wanna get all links which includes specific class.我想获得包含特定类的所有链接。 Therefore i am using this code:因此我正在使用此代码:
def getProductList(data, pageLinks):
content = BeautifulSoup(data.content, 'html.parser')
a = content.find_all("a", class_="sresult lvresult clearfix li shic")
print(a)
but im getting this output and i know that there are lots of links includes this class:但我得到了这个输出,我知道有很多链接包括这个类:
C:/Users/projects/getData.py
[]
I checked the doc and it should be true.我检查了文档,它应该是真的。 What is wrong with this code?这段代码有什么问题?
根据链接的文档,它应该是 class_= 而不是 class_:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.