TypeError: 'NoneType' object is not callable python
TypeError: 'NoneType' object is not callable python
我有一个错误
File "logins3", line 17, in <module>
my_inputs = soup.findall('input')
TypeError: 'NoneType' object is not callable
我的代码
# extract the token
soup = BeautifulSoup(response.content)
my_inputs = soup.findall('input')
for input in my_inputs:
print input.name + input['value'] #is here
信息
<input type="hidden" name="return" value="ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==" />
<input type="hidden" name="8d900dda34d7a3d37252b4a3c8" value="1" />
我需要这个令牌来创建我的脚本,但我不知道如何修复它
有
这是一个错字。
您打算使用 find_all()
而不是 findall()
。
仅供参考,这里 AttributeError
并没有失败,因为 BeautifulSoup
中的点符号具有特殊含义 - soup.findall
基本上是 soup.find("findall")
的快捷方式。换句话说,它试图找到名称为 findall
的元素,失败并返回 None
。这就是您获得 'NoneType' object is not callable
.
的方式
您需要在 soup.findall
中的 a
之前使用 _
my_inputs = soup.find_all('input')
或
>>> my_inputs = soup.findAll('input')
>>> for in_put in my_inputs:
print in_put.name , in_put['value']
input ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==
input 1
我有一个错误
File "logins3", line 17, in <module>
my_inputs = soup.findall('input')
TypeError: 'NoneType' object is not callable
我的代码
# extract the token
soup = BeautifulSoup(response.content)
my_inputs = soup.findall('input')
for input in my_inputs:
print input.name + input['value'] #is here
信息
<input type="hidden" name="return" value="ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==" />
<input type="hidden" name="8d900dda34d7a3d37252b4a3c8" value="1" />
我需要这个令牌来创建我的脚本,但我不知道如何修复它
有
这是一个错字。
您打算使用 find_all()
而不是 findall()
。
仅供参考,这里 AttributeError
并没有失败,因为 BeautifulSoup
中的点符号具有特殊含义 - soup.findall
基本上是 soup.find("findall")
的快捷方式。换句话说,它试图找到名称为 findall
的元素,失败并返回 None
。这就是您获得 'NoneType' object is not callable
.
您需要在 soup.findall
a
之前使用 _
my_inputs = soup.find_all('input')
或
>>> my_inputs = soup.findAll('input')
>>> for in_put in my_inputs:
print in_put.name , in_put['value']
input ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==
input 1