import csv
from bs4 import BeautifulSoup
from bs4.element import NavigableString
data = '''
<html>
<span>
Apples 43 0 0 0<br/>
Bananas 2282 0 500 0<br/>
Grapes 2534 0 500 0<br/>
Oranges 274 0 0 0<br/>
</span>
</html>'''
soup = BeautifulSoup(data, 'html.parser')
#print(soup.find_all("span"))
headers = ["Names", "Quantity", "SpareQty", "MinQty", "MaxQty"]
with open('output.csv', 'w', newline='') as f_output:
csv_output = csv.writer(f_output, delimiter=',')
csv_output.writerow(headers)
for br in soup.find_all("span"):
for item in br.contents:
if type(item) is not NavigableString:
continue
csv_output.writerow(item.strip().split())
С выводом.csv
Names,Quantity,SpareQty,MinQty,MaxQty
Apples,43,0,0,0
Bananas,2282,0,500,0
Grapes,2534,0,500,0
Oranges,274,0,0,0