BeautifulSoup 已安装,仍然是 miniconda 抛出属性错误

BeautifulSoup installed, still miniconda throwing Attribute error

我有一个小脚本 (bot.py) 来抓取链接,它使用 BeautifulSoup 和 urllib (python 3.4).

import urllib
import urllib.request as url_req
from bs4 import BeautifulSoup
import re


url = input('URL: ')
header = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' }

req = url_req.Request(url, headers=header)
try:
    response = url_req.urlopen(req)
except urllib.error.URLError as e:
    print(e.reason)

html = response.read()
soup = BeautifulSoup.BeautifulSoup(html)

for link in soup.findAll('a',   attrs={'href': re.compile("^http://")}):
    #print(link)
    print(link.get('href'))

当我在 Miniconda 中 运行 时,出现以下错误:

Traceback (most recent call last):
  File "StanBot.py", line 17, in <module>
    soup = BeautifulSoup.BeautifulSoup(html)
AttributeError: type object 'BeautifulSoup' has no attribute 'BeautifulSoup'

但是 BeautifulSoup 已经安装在 miniconda 中:

[py34] C:\Users\Anna\Desktop>conda list
# packages in environment at C:\Miniconda3\envs\py34:
#
beautiful-soup            4.3.2                    py34_1
beautifulsoup4            4.3.2                     <pip>
msvc_runtime              1.0.1                    vc10_0  [vc10]
pip                       7.1.2                    py34_0
python                    3.4.3                         4
setuptools                18.5                     py34_0
wheel                     0.26.0                   py34_1

[py34] C:\Users\Anna\Desktop>

我搜索了很多,但找不到合适的解决方案。这是什么原因造成的?

试试 soup = BeautifulSoup(html)