Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
cnn.CNNParser
politico.PoliticoParser
bbc.BBCParser
nosnl.NOSNLParser
""".split()

parser_dict = {}
Expand Down
33 changes: 33 additions & 0 deletions parsers/nosnl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from baseparser import BaseParser
from BeautifulSoup import BeautifulSoup, Tag


class NOSNLParser(BaseParser):
domains = ['www.nos.nl']

feeder_base = 'http://www.nos.nl'
feeder_pat = '^http://www.nos.nl/artikel/'

def _parse(self, html):
soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES,
fromEncoding='utf-8')

self.meta = soup.findAll('meta')

article = soup.find('div', id = 'article')
self.title = article.find('h1').getText()

article_content = soup.find('div', id = 'article-content')

self.byline = ''
self.date = article_content.find('abbr', 'page-last-modified').getText()

self.body = ''
for i in article_content.childGenerator():
if not isinstance(i, Tag):
continue
if not i.name == 'p':
continue

self.body += i.getText() + '\n\n'

1 change: 1 addition & 0 deletions website/frontend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def strip_prefix(string, prefix):
'edition.cnn.com': 'CNN',
'www.bbc.co.uk': 'BBC',
'www.politico.com': 'Politico',
'www.nos.nl': 'NOS.nl',
}

ancient = datetime(1901, 1, 1)
Expand Down
2 changes: 1 addition & 1 deletion website/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_articles(source=None, distance=0):
return articles


SOURCES = 'nytimes.com cnn.com politico.com bbc.co.uk'.split() + ['']
SOURCES = 'nytimes.com cnn.com politico.com bbc.co.uk nos.nl'.split() + ['']

@cache_page(60 * 30) #30 minute cache
def browse(request, source=''):
Expand Down