Reputation: 9705
Below is my code and the error I am getting
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
Error I am getting:
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
Upvotes: 2
Views: 1645
Reputation: 5292
Below is working to me- jobtitle
is class name of h2
not a
. I am with bs4 '4.4.0'
import requests
from bs4 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("h2", {"class", "jobtitle"})
for job in job_titles:
print job.text.strip()
Prints-
Management Associate - Access & Channel Management
Airline Customer Service Agent (Korean Speaker preferred) SF...
Event Concierge
Flight Checker
Office Automation Clerk
Administrative Assistant III
Operations Admin I - CA
Cashier Receptionist, Grade 3, (Temporary)
Receptionist/Office Assistant
Full-Time Center Associate
Upvotes: 0
Reputation: 368944
It seems like you're using BeautifulSoup 3 which does not have find_all
, but only findAll
.
Use findAll
if you will use BeautifulSoup 3.
Or use BeautifulSoup 4 to use find_all
:
from bs4 import BeautifulSoup
Upvotes: 2
Reputation: 11420
It shows that soup.find_all is None. Make sure that it's not none. Moreover, one more suspicious thing I notices in your code is imports
import BeautifulSoup
from BeautifulSoup import BeautifulSoup
Make sure that you import any one of them and accordingly modify
soup = BeautifulSoup(r.content)
Upvotes: 1