Issue
I am working with BeautifulSoup
for a web scraping project. I have a tag:
<span class="sal "><em class="iconRup"></em>40.0 Lacs</span>
and I want to retrieve 40.0 Lacs
from this.
I tried using :
salary = soup.find('span', class_ = 'sal')
print(salary.string())
but this gives a None object
. How to do I proceed?
Solution
This is how:
from bs4 import BeautifulSoup
html = """
<span class="sal "><em class="iconRup"></em>40.0 Lacs</span>
"""
soup = BeautifulSoup(html, "html.parser").find('span', class_='sal')
print(soup.getText())
Output:
40.0 Lacs
Answered By - baduker
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.