如何同时提取多个同种div下的第某个span标签(语言-python)

问题遇到的现象和发生背景

img

问题相关代码,请勿粘贴截图

targets2 = soup.find("div", class_="hd").select('span:nth-of-type(2)')

运行结果及报错内容

只能找到一个"div", class_="hd"的第二个span,但是用了find_all又不能用select。

我的解答思路和尝试过的方法

targets2 = soup.find_all("div", class_="hd")
只能获取第一个span
targets = soup.find_all("span", class_="title")
又会同时获取多个class_="title"的电影名

我想要达到的结果

想要爬取所有豆瓣top250电影第二个电影名

先获取所有class='hd'的div保存到列表中,然后遍历列表中每一项获取这一项div的第二个span

targets2 = soup.find_all("div", class_="hd")
for item in targets2:
    print(item.select('span:nth-of-type(2)'))

find_all定位div标签,然后遍历这个定位对象,每次遍历再定位span即可