【发布时间】:2014-09-25 12:18:22
【问题描述】:
我有一个简单的 python 脚本,例如:
#!/usr/bin/python
import requests
import BeautifulSoup
response = requests.get('http://site.ir/')
out=response.content
soup = BeautifulSoup.BeautifulSoup(out)
for anchor in soup.select('body a'):
print anchor.string
但是出现以下错误:
File "p.py", line 11, in <module>
for anchor in soup.select('body a'):
TypeError: 'NoneType' object is not callable
图片:
【问题讨论】:
-
我将删除我的答案,因为您一直在更改问题;它不再有效。您现在正在使用 BeautifulSoup 3 尝试使用 BeautifulSoup 4 功能。
-
你看过返回的内容了吗?
-
@Martijn Pieters 谢谢...你能提出新的答案吗?我不知道 3 和 4 之间的区别,请原谅让您忙...
-
@Padraic Cunningham 它返回了你在帖子中看到的错误,
-
我的意思是你的html返回了,我不认为它返回你认为的那样
标签: python beautifulsoup