问答详情
源自:3-4 BeautifulSoup使用

错误求解决

#!/usr/bin/env python
# -*- coding:utf-8 -*-
from urllib import request
from bs4 import BeautifulSoup as bs
req=request.Request("http://www.baidu.com")
req.add_header("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36")
resp=request.urlopen(req)
soup=bs(resp,"html_parser")
print(soup.img)


Traceback (most recent call last):
  File "C:/Users/Administrator.WIN7-20160710FD/PycharmProjects/untitled1/pc1.py", line 4, in <module>
    from bs4 import BeautifulSoup as bs
ImportError: No module named 'bs4'

Process finished with exit code 1



提问者:k2nn3 2016-10-09 13:48

个回答

  • 秋名山车神
    2016-10-09 14:34:03

    这应该是你没有安装 BeautifulSoup4的缘故