【发布时间】:2016-01-11 15:48:45
【问题描述】:
我已经重写了两次,我看不到问题,我在 python 2 上安装了 mechanize,我没有同时使用制表符和空格,我只使用空格。
import urllib
from bs4 import BeautifulSoup
import re
import urlparse
import mechanize
url = "http://www.dailymail.co.uk/home/index.html"
br = mechanize.Browser()
br.open(url)
for link in br.links():
print link
错误是
Traceback (most recent call last):
File "mechanize.py", line 4, in <module>
import mechanize
File "/home/ro/Autoblog/mechanize/mechanize.py", line 8, in <module>
br = mechanize.Browser()
AttributeError: 'module' object has no attribute 'Browser'
【问题讨论】:
-
/home/ro/Autoblog/mechanize/mechanize.py是指向mechanize的路径还是隐藏了真正的模块? -
是的,这就是问题所在,感谢您的帮助。
标签: python attributes mechanize