def load_logs(self, start, end, log_filter):
try:
response = urllib.request.urlopen(self.get_url(start, end, log_filter))
except urllib.error.URLError as err:
print("Error reading from network: %s" % err)
return []
body = response.read().decode('utf-8')
events = []
for line in body.split('\n'):
match = re.match(r'.*?(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}'
r'.\d{6}[-+]\d{2}:\d{2}).*path="([^"]+)".*', line)
if match:
path = self.filter_path(match.groups()[1])
when = iso8601.parse_date(match.groups()[0])
events.append((when, path))
return events
评论列表
文章目录