When asking questions, it is always best to post what code you’ve already tried so people can help you to understand where you are going wrong as opposed to providing solutions for you.
With that said, titles can be accessed as shown below. All of this and more is mentioned in the docs: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#attributes
from bs4 import BeautifulSoup
HTML = b"""
<html>
<head>
<title>Problem with BeautifulSoup</title>
</head>
<body>
<div title="A title">Content</div>
</body>
</html>
"""
soup = BeautifulSoup(HTML, 'html.parser')
print(soup.select_one('div')["title"])
I’m not sure I 100% understand what you are asking, but maybe this helps. My approach is to usually use CSS selectors. I have an obvious bias for using CSS selectors as I am the author of the CSS selector library that Beautiful Soup uses. You can learn more about all the support CSS pseudo-classes etc. by checking out the documentation here.
from bs4 import BeautifulSoup
HTML =
"""
<div class="text-success">
<div title="Pick me 1"></div>
<div title="not me 1"></div>
</div>
<div class="text-warning">
<div title="Pick me 2"></div>
<div title="not me 2"></div>
</div>
"""
soup = BeautifulSoup(HTML, 'html.parser')
books_list = [el['title'] for el in soup.select("div:is(.text-success, .text-warning) > div:first-child")]
print(books_list)
Output:
['Pick me 1', 'Pick me 2']