BeautifulSoup returns 'none'

2987 views python

I accept to get h2-tag text but it shows me 'none'. It exists. I have tried to changed the page.content 'html.parser to lxml' so and so on. Still it's not working.

from bs4 import BeautifulSoup
import requests

headers = {"User-agent":"Mozilla/5.0 (X11; Linux x86_64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 
url = ''
page = requests.get(url,headers=headers).text
soup = BeautifulSoup(page, 'html.parser')
div = soup.find('div', class_='col-xs-12').h2

I have tried to change page content in xml after that that it shows elif len(markup) <= 256 and ( TypeError: object of type 'Response' has no len()

answered question
Rob Kwasowski

Can you explain a bit better what you're trying to do? What is the .h2 for?

Add a Comment

1 Answer


To find an <h2> Element inside of the <div>, you can use another .find() method on the <div> that you're finding:

div = soup.find('div', class_='col-xs-12')
heading = div.find('h2')

posted this

Please login first before posting an answer.