how to select p of a dib without selecting any sub division p in beautifulsoup code example
Example 1: get title attribute beautiful soup
for body in message.find_all('div', {'class': 'body'}):
if body.find('div', {'class': 'date'}):
text = body.find('div', {'class': 'date'})
title = text.get('title', 'No title attribute')
print(title)
Example 2: scrape text from specific p tag
from bs4 import BeautifulSoup
import urllib
url = urllib.urlopen('http://meinparlament.diepresse.com/')
content = url.read()
soup = BeautifulSoup(content, 'lxml')
table = soup.findAll('div',attrs={"class":"content-question"})
for x in table:
print x.find('p').text