MildyS
MildyS

Reputation: 15

Python BeautifulSoup - just Text

I want to scrape from the web some information like price etc. and then I want to put it into table, but my output is:

['789\xa0€']
['Na sklade > 5\xa0ks']

on the website, it is:

<span>789&nbsp;€</span>
<span>5&nbspks</span>

I want to get rid of that &nbsp (or \n) but how?

Upvotes: 1

Views: 88

Answers (1)

bigbounty
bigbounty

Reputation: 17368

In [46]: import unicodedata

In [47]: a = ['789\xa0€','Na sklade > 5\xa0ks']

In [48]: unicodedata.normalize("NFKD", a[1])
Out[48]: 'Na sklade > 5 ks'

In [49]: unicodedata.normalize("NFKD", a[0])
Out[49]: '789 €'

Upvotes: 2

Related Questions