简体   繁体   English

为什么当我尝试使用 find_all 函数在 Python 3.8 中使用 bs4 通过带有“class_”的 css 进行搜索时得到一个空列表?

[英]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.

相关问题 打印“find_all”的结果(使用 bs4 库)返回一个空列表(但我引用的类存在) - Printing the result of a "find_all" (using bs4 library) returns an empty list (but the class I'm referencing exists) BS4按类别搜索_返回空 - BS4 Searching by Class_ Returning Empty 为什么在尝试使用 bs4 获取包含 python 中特定类的链接时获取空列表? - Why getting empty list while try to get links which includes specific class in python using bs4? Python BS4 find()find_all()返回空列表 - Python BS4 find() find_all() returns empty lists 使用 find_all 通过 BeautifulSoup 在 BS4 中查找某个类 - Using find_all to find a certain class in BS4 with BeautifulSoup 为什么bs4返回标签,然后向此find_all()方法返回一个空列表? - Why does bs4 return tags and then an empty list to this find_all() method? 在BS4中使用find_all将文本作为列表获取 - Using find_all in BS4 to get text as a list Python中BS4 find_all()语句中的过滤功能问题 - Filtering function issues in BS4 find_all() statement in Python Python BS4没有在find_all()函数中返回Unicode值 - Python BS4 not returning a Unicode value in find_all() function Regardless of CSS class element input to find_all() function of BeautifulSoup, I receive an empty list as output - Regardless of CSS class element input to find_all() function of BeautifulSoup, I receive an empty list as output
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM