Open ndarville opened 10 years ago
from baseparser import BaseParser
from BeautifulSoup import BeautifulSoup
class InformationParser(BaseParser):
feeder_pat = '^http://www.b.dk/(nationalt|politiko|globalt)/'
feeder_pages = ['http://www.b.dk/nyhedsoversigt']
def _parse(self, html):
"""Retrieve and serve the required fields to create an entry."""
soup = BeautifulSoup(html,
convertEntities=BeautifulSoup.HTML_ENTITIES,
fromEncoding='utf-8')
self.meta = soup.findAll('meta')
self.title = soup.find('h1').getText()
self.date = ""
self.byline = soup.find('span', {'itemprop': 'author'}).next.getText()
summary = soup.find('div', 'manchet').getText()
content = soup.find('div', {'itemprop': 'articleBody'}.getText()
self.body = summary + content