Home > database >  Beautifulsoup datascrapping collect number from website
Beautifulsoup datascrapping collect number from website

Time:09-25

hi i would like to use beautifulsoup to extract number. below is the code:

future=data3.find_all('span',class_='instrument-price_last__KQzyA')


print(future)



it will return: span class="instrument-price_last__KQzyA" data-test="instrument-price-last">23,989.5</span

how can i extract the 23989.5 out of this information? Thank you

CodePudding user response:

Use the text attribute:

future = float(data3.find_all('span',class_='instrument-price_last__KQzyA').text.replace(',', ''))

And:

print(future)

Would give:

23989.5
  • Related