I web scraped some stock tickers off a website and the text inside the span tags has '\xa0AYTU\xa0'
as an example. I'm trying to remove '\xa0'
from either side of the ticker using replace('xa0','')
. However, when I go to append the list after I replaced the characters it appends the list with '\xa0AYTU\xa0'
no matter what..
Here is my for loop in question.
fu_tickers = []
for t in match_fu.find_all('span'):
temp = str(t.text)
temp2 = temp.replace('xa0','')
fu_tickers.append(temp2)
print(fu_tickers)
When I insert print(temp2)
inside the for loop I can see it properly removes the characters but for some reason will not append temp2
string to the fu_tickers
list with the characters removed.
Current results = ['\xa0AYTU\xa0', '\xa0CETX\xa0', '\xa0CHFS\xa0']
Desired results = ['AYTU', 'CETX', 'CHFS']