2

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

3 Answers 3

2

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
Sign up to request clarification or add additional context in comments.

Comments

1

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)

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.