我有一个简单的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
图片
答案 0 :(得分:0)
安装BeautifulSoup4并执行以下操作:
import requests
from bs4 import BeautifulSoup
soup = BeautifulSoup(requests.get('http://site.ir/').content)
for anchor in soup.select('body a'):
print anchor.text