[英]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" />
我需要此令牌來創建我的腳本,但看不到如何解決它
ty
這是一個錯字。
您打算使用find_all()
而不是findall()
。
僅供參考,在這里不會因AttributeError
而失敗,因為BeautifulSoup
的點符號具有特殊含義soup.findall
基本上是soup.find("findall")
快捷方式。 換句話說,它嘗試查找具有findall
名稱的元素,失敗並返回None
。 這就是您'NoneType' object is not callable
。
您需要使用_
之前a
在soup.findall
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.