aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2019-01-22 20:06:48 +0100
committerFélix Sipma <felix.sipma@no-log.org>2019-01-22 20:06:48 +0100
commit22e578c21c9164716006a8f6b4b6984403b99071 (patch)
treee1c0e598431b63e970dea46ed4942c15a51d9ebc
parent8233122a6ffdbc48a0baa271c9683601a7f9907d (diff)
update confederationpaysanne.py filter
-rwxr-xr-xdoc/filters/confederationpaysanne.py56
1 files changed, 34 insertions, 22 deletions
diff --git a/doc/filters/confederationpaysanne.py b/doc/filters/confederationpaysanne.py
index 0a50fa1..09a52d6 100755
--- a/doc/filters/confederationpaysanne.py
+++ b/doc/filters/confederationpaysanne.py
@@ -31,7 +31,7 @@ import logging
from dateutil.parser import parse
import datetime
-__version__ = "0.1"
+__version__ = "0.2"
# Defaults
feed_title = None
@@ -80,7 +80,7 @@ if not feed_title:
entries = []
if soup.body.find("div", {"id": "res-recherche"}):
- content = soup.body.find("div", {"id": "res-recherche"}).findAll('h5')
+ content = soup.body.find("div", {"id": "res-recherche"}).findAll("div", {"class": "d-text" })
for section in content:
entry = {
'title': "",
@@ -89,28 +89,40 @@ if soup.body.find("div", {"id": "res-recherche"}):
'date': ""
}
nextNode = section
+
+ ## date
+ rawdate = nextNode.find("span", {"class": "f-date"}).text
+ if rawdate:
+ entry['date'] = rawdate
+
+ ## title
+ rawtitle = nextNode.find("h5")
entry['title'] = " ".join(
- [line.strip() for line in nextNode.text.strip().splitlines()]
+ [line.strip() for line in rawtitle.text.strip().splitlines()]
)
- entrycontent = []
- while True:
- try:
- nextNode = nextNode.nextSibling
- if nextNode:
- entrycontent.append(unicode(nextNode))
- except AttributeError:
- break
- try:
- tag_name = nextNode.name
- except AttributeError:
- tag_name = ""
- if tag_name == "span":
- rawdate = nextNode.find("span", {"class": "f-date"}).text
- if rawdate:
- entry['date'] = rawdate
- elif tag_name == "hr":
- break
- entry['content'] = entrycontent
+
+ ## content
+ entry['content'] = nextNode.text
+
+ #entrycontent = []
+ #while True:
+ # try:
+ # nextNode = nextNode.nextSibling
+ # if nextNode:
+ # entrycontent.append(unicode(nextNode))
+ # except AttributeError:
+ # break
+ # try:
+ # tag_name = nextNode.name
+ # except AttributeError:
+ # tag_name = ""
+ # if tag_name == "span":
+ # rawdate = nextNode.find("span", {"class": "f-date"}).text
+ # if rawdate:
+ # entry['date'] = rawdate
+ # elif tag_name == "hr":
+ # break
+ #entry['content'] = entrycontent
entries.append(entry)