Issue
I want to get all title value from this bs4 resultset?
[<span class="zaman" title="16.3.2022 15:22:44">1 hf.</span>, <span class="hide zaman pull-right ml-5 mt--1">( Mesaj Silindi )</span>,<span class="zaman" title="16.3.2022 15:32:01">1 hf.</span>, <span class="hide zaman pull-right ml-5 mt--1">( Mesaj Silindi )</span>]
How can I get all value of title like 16.3.2022 15:22:44 , 16.3.2022 15:32:01 etc?
Solution
I'm getting the digits value as follows:
html='''
<span class="zaman" title="16.3.2022 15:22:44">
1 hf.
</span>
,
<span class="hide zaman pull-right ml-5 mt--1">
( Mesaj Silindi )
</span>
,
<span class="zaman" title="16.3.2022 15:32:01">
1 hf.
</span>
,
<span class="hide zaman pull-right ml-5 mt--1">
( Mesaj Silindi )
</span>
'''
from bs4 import BeautifulSoup
soup= BeautifulSoup(html,'html.parser')
#print(soup.prettify())
value = [x.get('title') for x in soup.find_all('span', class_="zaman")]
value=value[0]+ ' , ' + value[2]
print(value)
Output:
16.3.2022 15:22:44 , 16.3.2022 15:32:01
Answered By - F.Hoque
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.