2019-12-31 21:45:14 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Yuuki_Libs
|
2020-02-01 13:58:50 +08:00
|
|
|
(c) 2020 Star Inc.
|
2019-12-31 21:45:14 +08:00
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
"""
|
2019-12-29 22:26:47 +08:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
2020-01-29 14:31:01 +08:00
|
|
|
|
2019-12-29 22:26:47 +08:00
|
|
|
class Yuuki_WebDataReader:
|
|
|
|
def __init__(self, Yuuki_Data):
|
|
|
|
self.handle = Yuuki_Data
|
|
|
|
|
2020-02-08 00:55:19 +08:00
|
|
|
def get_logs(self, name):
|
2019-12-29 22:26:47 +08:00
|
|
|
if name not in self.handle.LogType:
|
|
|
|
return {"status": 404}
|
|
|
|
with open(
|
|
|
|
self.handle.LogPath
|
|
|
|
+
|
|
|
|
self.handle.LogName.format(name)
|
|
|
|
) as file:
|
|
|
|
html_doc = file.read()
|
|
|
|
parser = BeautifulSoup(html_doc, 'html.parser')
|
|
|
|
events = parser.find_all('li')
|
2020-02-08 00:55:19 +08:00
|
|
|
return [result.string for result in events]
|