Home > Mobile >  Beautifulsoup data scraping collect number from website
Beautifulsoup data scraping collect number from website

Time:09-27

I would like to use beautifulsoup to extract number. My code is as follows:

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