I want to get all title value from this bs4 resultset?
[<span title="16.3.2022 15:22:44">1 hf.</span>, <span >( Mesaj Silindi )</span>,<span title="16.3.2022 15:32:01">1 hf.</span>, <span >( 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?
CodePudding user response:
I'm getting the digits value as follows:
html='''
<span title="16.3.2022 15:22:44">
1 hf.
</span>
,
<span >
( Mesaj Silindi )
</span>
,
<span title="16.3.2022 15:32:01">
1 hf.
</span>
,
<span >
( 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