I have this span and I want to get the title
<span title="Something"></span>
How to get that with beautifulsoup?
res = soup.find('span')
print res //Was trying to add res.title but result is 'None'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should be able to access it like this:
res = soup.find('span')['title']Docs
Edit: I shoudl clarify, res would then be the value of the title attribute. If you want the element to use later, change my code to:
Then you could keep using
res(if needed).Also,
.findis going to return a single element. You’ll want to make sure it is the span you want, since the HTML could have more than one span.