BeautifulSoup and Requests Module NoneType Error

2343 views python

I've been experimenting with the requests and the bs4 module for a couple of days now. I wanted to make a simple program similar to the 'I'm Feeling Lucky' from google.

Here's my code:

import requests, bs4, webbrowser


exsoup=bs4.BeautifulSoup(source, 'lxml')
# <cite class="iUh30"></cite>
match=exsoup.find('cite', class_='iUh30')


But when I run this I get the following error:

AttributeError: 'NoneType' object has no attribute 'text'

How can I make this work?

answered question

1 Answer


You can use the following code instead of exsoup.find('cite', class_='iUh30')

exsoup.find_all('cite',{'class': 'iUh30'})

posted this

Have an answer?


Please login first before posting an answer.