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>
.
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
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>
.
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