1

不太明白为什么我会收到此跟踪错误:

Traceback (most recent call last):
  File "S:/Personal Folders/Andy/Python Projects/Salesforce BZ API/Automated Reports.py", line 15, in <module>
    parse = br.soup("find('div')")
  File "build\bdist.win32\egg\spynner\browser.py", line 409, in _get_soup
    return self._html_parser(self.html)
TypeError: 'str' object is not callable

这是我的代码:

from __future__ import division
#from __future__ import unicode_literals
from __future__ import print_function
import spynner
from BeautifulSoup import BeautifulSoup

#Loading up Salesforce

br = spynner.Browser()
#br.debug_level = spynner.DEBUG
br.create_webview()
br.show()
br.set_html_parser("BeautifulSoup")
br.load("https://login.salesforce.com/")
parse = br.soup("find('div')")
print(parse)
br.browse()
br.close()
4

2 回答 2

5

看起来您将 HTML 解析器设置为字符串“BeautifulSoup”,而不是 BeautifulSoup。我没有安装它,所以我无法测试它是否有效,但值得一试。

于 2011-08-08T21:06:11.447 回答
0

我在这里快速浏览了一下,它似乎soup不是函数而是属性。

于 2011-08-08T21:05:12.300 回答