How to get the "title" from the <span>

Question:

How can I get the title "Product Manager" from the code below?

<div class="new_job_name" data-v-99ef4628="">
    <span data-v-99ef4628="">Product Manager</span>
</div>

If the title was in the <div class= "new_job_name">, I can get it using the code below:

soup.find(class_="new_job_name").attrs["title"]

Now I have no idea how to get the "title" within the <span> under the <div class>.

Asked By: Radish

||

Answers:

You can just find the span inside the div with class new_job_name

soup.find(class_="new_job_name").find('span').text

Note: I have framed this answer based on your HTML, if there are multiple div with class new_job_name then you need to loop through the array

Answered By: Tushar
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.