1. 出错位置:
soup.find_all函数无法使用,总是在报错,报以下类似的错误:
print soup.find_all('body') TypeError: 'NoneType' object is not callable
find_all是BeautifulSoup4的写法,在3.0以前是其他写法。
此次解决方案采用升级BeautifulSoup4的方式。
2.解决方案:
2.1. 安装新版本BeautifulSoup代码
2.2. 代码层面:
from BeautifulSoup import *
换为
from bs4 import BeautifulSoup
原因是上面的写法是BeautifulSoup的3.0版本以前的写法,下面是新的写法。
ps: soup.find_all('span') 的写法等同于 soup('span')