search

Home  >  Q&A  >  body text

python3.6通过urlopen打开一个以html结尾的网址,再转换成BeautifulSoup打印这个对象为空为什么?

htmlobj = urlopen('http://www.58pic.com/haibao/0/dnum-1.html')
soup = BeautifulSoup(htmlobj, "lxml")
print(soup)
迷茫迷茫2781 days ago670

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:24:48

    Please compare the codes

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 10:24:48

    You should be like this

    htmlobj = urlopen('http://www.58pic.com/haibao/0/dnum-1.html')
    soup = BeautifulSoup(htmlobj.read(), "lxml")
    print(soup)

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:24:48

    ubuntu 16.04, python3.5
    The original code can be output and is not empty

    If urlopen does return null, the usual error is that the server does not exist.

    reply
    0
  • Cancelreply