support sondages

This commit is contained in:
Romain Bignon 2011-03-21 10:56:02 +01:00
commit c74bd6e028
3 changed files with 8 additions and 1 deletions

View file

@ -40,6 +40,7 @@ class DLFP(BaseBrowser):
'https://linuxfr.org/wiki/nouveau': WikiEditPage,
'https://linuxfr.org/wiki/[^\.]+/modifier': WikiEditPage,
'https://linuxfr.org/suivi/[^\.]+': ContentPage,
'https://linuxfr.org/sondages/[^\.]+': ContentPage,
'https://linuxfr.org/users/[\w\-_]+/journaux/[^\.]+': ContentPage,
'https://linuxfr.org/forums/[\w\-_]+/posts/[^\.]+': ContentPage,
'https://linuxfr.org/nodes/(\d+)/comments/(\d+)': CommentPage,

View file

@ -166,7 +166,7 @@ class ContentPage(DLFPPage):
if not self.article:
self.article = Article(self.browser,
self.url,
select(self.document.getroot(), 'article', 1))
select(self.document.getroot(), 'div#contents article', 1))
try:
threads = select(self.document.getroot(), 'ul.threads', 1)

View file

@ -24,6 +24,7 @@ URL2ID_DIARY_RE = re.compile('.*/users/([\w\-_]+)/journaux/([^\.]+)')
URL2ID_NEWSPAPER_RE = re.compile('.*/news/(.+)')
URL2ID_WIKI_RE = re.compile('.*/wiki/([^ /]+)')
URL2ID_SUIVI_RE = re.compile('.*/suivi/([^ /]+)')
URL2ID_SONDAGE_RE = re.compile('.*/sondages/([^ /]+)')
URL2ID_FORUM_RE = re.compile('.*/forums/([\w\-_]+)/posts/([^\.]+)')
def rssid(entry):
@ -57,6 +58,8 @@ def id2url(id):
return '/forums/%s/posts/%s' % (m.group(2), m.group(3))
if m.group(1) == 'S':
return '/suivi/%s' % m.group(3)
if m.group(1) == 's':
return '/sondages/%s?results=1' % m.group(3)
def url2id(url):
m = URL2ID_NEWSPAPER_RE.match(url)
@ -74,6 +77,9 @@ def url2id(url):
m = URL2ID_SUIVI_RE.match(url)
if m:
return 'S.%s' % (m.group(1))
m = URL2ID_SONDAGE_RE.match(url)
if m:
return 's.%s' % (m.group(1))
def id2threadid(id):
m = ID2URL_RE.match(id)