类型错误: 'NoneType' 对象不是可调用的蟒蛇
问题描述:
我有一个错误类型错误: 'NoneType' 对象不是可调用的蟒蛇
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" />
我需要这个令牌创建我的脚本我看不到如何修复它
ty
答
您需要在soup.findall
my_inputs = soup.find_all('input')
OR
>>> my_inputs = soup.findAll('input')
>>> for in_put in my_inputs:
print in_put.name , in_put['value']
input ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==
input 1
a
之前使用
_
答
这是一个错字。
你打算使用find_all()
而不是findall()
。
仅供参考,它并没有失败,AttributeError
这里,因为在BeautifulSoup
点符号有特殊的含义 - soup.findall
基本上快捷方式soup.find("findall")
。换句话说,它试图找到名称为findall
的元素,失败并返回None
。这就是你如何得到'NoneType' object is not callable
。