美丽的汤在解析机械化的输出时遇到问题

时间:2016-09-03 23:37:38

标签: mechanize

def return_with_soup(url):
    #uses mechanize to tell the browser we aren't a bot
    #and to retrieve webpage
    #returns a soupified webpage
    browser = mechanize.Browser()    #I am made of human
    browser.set_handle_robots(False) #no bots here, no sir
    browser.open(url)
    #print browser.response().read()
    soup = BeautifulSoup(browser.response().read()) #this is where it breaks
    return soup

在引用倒数第二行时出现此错误“类型错误:模块不可调用”

到底发生了什么?

1 个答案:

答案 0 :(得分:0)

BeautifulSoup作为模块导入。所以我不得不改变这一行:

BeautifulSoup.BeautifulSoup(...)