Python BeautifulSoup仅查找html标记(无类)

Python BeautifulSoup仅查找html标记(无类),python,html,Python,Html,嘿,伙计们,我目前正在PyCharm中学习Python,我一直在学习一些教程 并具有以下工作代码: import requests from bs4 import BeautifulSoup import operator def start(url): word_list = [] source_code = requests.get(url).text

嘿,伙计们,我目前正在PyCharm中学习Python,我一直在学习一些教程

并具有以下工作代码:

        import requests
        from bs4 import BeautifulSoup
        import operator


        def start(url):
            word_list = []
            source_code = requests.get(url).text
            soup = BeautifulSoup(source_code)
            for post_text in soup.findAll('a', {'class': 'index_singleListingTitles'}):
                content = post_text.string
                words = content.lower().split() #make all lower case and splits it up (based on spaces)
                for each_word in words:
                    print(each_word)
                    word_list.append(each_word)

        start('https://www.thenewboston.com/tops.php?type=text&period=this-month')
但我关注的代码是:对于soup.findAll'a'中的post_文本,{'class':'index_singleListingTitles'}:它使用BeautifulSoup对网页的html源代码进行排序,以查找标记、类等。。并获取信息

我似乎无法将其设置为查找以下内容的强标记:

<a href="/anime/5114/Fullmetal_Alchemist:_Brotherhood" class="hoverinfo_trigger" id="#area5114" rel="#info5114"><strong>Fullmetal Alchemist: Brotherhood</strong></a>
我知道大多数网页都有反对废弃它们的tos,我这样做只是为了尝试其他网站,只有一个网页,我没有制作任何程序或任何有害的东西,只是学习

我尝试了很多东西,我开始觉得它在我尝试的网页上不起作用,但我怀疑BeautifulSoup是否有可能阻止


任何帮助都会很好,我只学了2天python,所以对我放松点!谢谢。

您正在查找的页面没有任何强标签。使用所需的标记为您的测试创建一个本地html页面,然后在上面播放。很抱歉,我没有使用该页面,我给出了一个工作代码示例,然后是另一个站点和页面的代码片段。虽然很清楚,但由于权限原因,没有添加其他网站,只有其他网站需要的代码片段。你能创建一个示例页面并将其发布在gist上吗?因为精确解会因页面内容的不同而不同。