【问题标题】:Parsing russian site encoding error解析俄罗斯站点编码错误
【发布时间】:2018-08-14 15:26:29
【问题描述】:

解析网站https://beton24.ru/sochi/beton/时编码有问题

from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen('https://beton24.ru/sochi/beton/')
bs = BeautifulSoup(html.read())
result = bs.findAll("span", "catalog-index__link-text")[1]
parse = str(result)

为了得到混凝土的价格,我将结果转换为str,它变成了'from \ xa03 \ u2009836 \ xa0₽'

谁遇到过,怎么解决?谢谢!

【问题讨论】:

  • 你期待什么?
  • @AzatIbrakov urllib.request 表示 Python 3,包含 \u 转义的 str 也是如此。

标签: python python-3.x parsing encoding beautifulsoup


【解决方案1】:

我想你想要的是:

parse = result.text

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多