Commit 86487554360ce167278886788f57dc2ae4adb666

Authored by Geoffrey PREUD'HOMME
1 parent 2ae9506d

Support de la date de modification

Showing 1 changed file with 4 additions and 5 deletions   Show diff stats
parse.py
... ... @@ -4,6 +4,7 @@ import sys
4 4 import argparse
5 5 import datetime
6 6 import urllib.request
  7 +import dateutil.parser
7 8 from icalendar import Calendar
8 9 from html.parser import HTMLParser
9 10 from icalendar import vDatetime, Calendar, Event as CalEvent
... ... @@ -119,9 +120,6 @@ class TableHTMLParser(HTMLParser):
119 120 if self.iscell():
120 121 self.cell += data
121 122  
122   -# TODO Use HTTP header date
123   -UPDATE_TIME = datetime.datetime.now()
124   -
125 123 # TODO Do something that really is OOP or do not...
126 124  
127 125 class Event:
... ... @@ -197,11 +195,12 @@ class Event:
197 195 e.add('dtstart', self.startTime)
198 196 e.add('dtend', self.endTime)
199 197 e.add('location', self.location)
200   - e.add('last-modified', UPDATE_TIME)
201   - e.add('dtstamp', UPDATE_TIME)
  198 + e.add('last-modified', updateTime)
  199 + e.add('dtstamp', updateTime)
202 200 return e
203 201  
204 202 with urllib.request.urlopen(url) as handle:
  203 + updateTime = dateutil.parser.parse(handle.headers['Last-Modified'])
205 204 htmlStr = handle.read().decode('iso-8859-15')
206 205  
207 206 # Read HTML tables
... ...