简体   繁体   中英

python 3 Beautiful Soup, currency symbol

i'm parsing a page using beautiful soap 4.4. all the local language symbols are shown correctly. except the currency sign - for it i'm getting a symbols like this:

฿1,500
฿120
฿790,000

related code:

soup = BeautifulSoup(r.text.replace('<!--', '').replace('-->', ''), 'lxml')
items_list = soup.findAll('div', id=re.compile('^post_'))
price = item.div.contents[1].contents[1].text

what is the right way to get the currency symbols?

upd. html:

<div><div class="_sz6">฿790,000</div></div>

make sure the encoding of the response is 'utf-8'

if r.encoding != 'utf-8':
    r.encoding = 'utf-8'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM