from bs4 import BeautifulSoup
URL = "https://www.worldometers.info/coronavirus/"
r = requests.get(URL)
soup = BeautifulSoup(r.content, 'html5lib')
countHTML = soup.find('div', attrs = {'class':'content-inner'})
for countVar in countHTML.findAll('div', attrs = {'class':'maincounter-number'}):
count = countVar.span
Right now variable count returns:
<span style="color:#aaa">270,069</span>
<span>11,271</span>
<span>90,603</span>
I need help on extracting 3 separate integers from this string, I have tried count[0] but this is not an array so it does not work.
String1 = "270,069"
String2 = "11,271"
String3 = "90,603"
Then converts into 3 integers by removing the comma
Int1 = 270069
Int2 = 11271
Int3 = 90603
Perhaps Regex will help?
Edit:
I currently have numbers = [] as one value in a list, such as
numbers = """
270069
11271
90603"""
so if I do numbers[0], all 3 integers will show up as 1 value, how do I strip new lines, and make them into a list or array with 3 separate values?