I was using BeautifulSoup to extract the job title from indeed, there are s span <>tags which one of them contains the title info.
the h2 tag:
<h2 >
<div >
<span >new</span>
</div>
<span title="Entry Level Software Developer">Entry Level Software Developer</span>
</h2>
Here`s a piece of my code sample:
divs = soup.find_all("div", class_="job_seen_beacon")
for item in divs:
title_span = item.find('h2', class_="jobTitle")
title = title_span.find_all(title=True)
when running it, I can only get the list that contains the title.
[<span title="Entry Level Software Developer">Entry Level Software Developer</span>]
How can extract the title text from it, or is there another way to perform this task?
CodePudding user response:
You need to get It's text property.
title = [span.text for span in title_span.find_all(title=True)]
My guess, there will be only one title, you can use:
title = title_span.find(title=True)