Python 类型错误:';非类型';对象不可调用
我有个错误Python 类型错误:';非类型';对象不可调用,python,beautifulsoup,Python,Beautifulsoup,我有个错误 File "logins3", line 17, in <module> my_inputs = soup.findall('input') TypeError: 'NoneType' object is not callable 信息 <input type="hidden" name="return" value="ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==" /> &l
File "logins3", line 17, in <module>
my_inputs = soup.findall('input')
TypeError: 'NoneType' object is not callable
信息
<input type="hidden" name="return" value="ovL2FuaW1lZGlnaXRhbG5ldHdvcmsuZZXgucGhwL2Nvbm5leGlvbg==" />
<input type="hidden" name="8d900dda34d7a3d37252b4a3c8" value="1" />
我需要这个令牌来创建我的脚本,我不知道如何修复它
这是一个打字错误
您打算使用而不是findall()
仅供参考,这里的
AttributeError
没有失败,因为BeautifulSoup
中的点符号有一个特殊的含义-soup.findall
基本上是soup.find(“findall”)的快捷方式。换句话说,它试图找到一个名为findall
的元素,但失败并返回None
。这就是为什么'NoneType'对象不可调用的原因
您需要在汤中的a
之前使用
。findall
my_inputs = soup.find_all('input')
或
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