下面是我的代码和我得到的错误
import requests
import BeautifulSoup
from BeautifulSoup import BeautifulSoup
url = "http://www.indeed.com/jobs? q=hardware+engineer&l=San+Francisco%2C+CA"
r = requests.get(url)
soup = BeautifulSoup(r.content)
job_titles = soup.find_all("a", {"class", "jobtitle"})
print job_titles
我得到的错误:
Traceback (most recent call last):
File "webscraping.py", line 13, in <module>
job_titles = soup.find_all("a", {"class", "jobtitle"})
TypeError: 'NoneType' object is not callable
3 回答
以下是我的工作 -
jobtitle
是h2
的类名a
. 我和bs4 '4.4.0'
Prints-
看起来你正在使用的BeautifulSoup 3没有
find_all
,只有findAll
.如果您将使用BeautifulSoup 3,请使用findAll .
或使用BeautifulSoup 4使用find_all:
它表明soup.find_all是None . 确保它不是没有 . 而且,我在你的代码中注意到的另一个可疑的东西是导入
确保导入其中任何一个并进行相应的修改