I am scraping a site with python3 using beautiful Soup. I store my data into a list.
I manage to extract the info that i want
import requests
from bs4 import BeautifulSoup
source = requests.get('my site').text
soup = BeautifulSoup(source, 'lxml')
lista = []
rows = soup.find('table', class_='exchange-rates-table not-
responsive').find_all('tr')
for row in rows: # Print all occurrences
l.ista.append(row.contents[3].get_text())
print(lista)
This is the output:
['Cod', '\n\n EUR\n\n ',
'\n\n USD\n\n ', '\n\n
GBP\n\n ', '\n\n CHF\n\n
', '\n\n AUD\n\n ', '\n\n
DKK\n\n ', '\n\n HUF\n\n
', '\n\n JPY\n\n ', '\n\n
NOK\n\n ', '\n\n SEK\n\n
']
When i run this code i am receiving the info that i want, but with a lot of empty spaces with comma between them and the sign of new line. So how can i remove them to get only what i want.