anynews Page class:


SUBMITTED BY: hegias

DATE: Feb. 22, 2023, 5:22 p.m.

FORMAT: Python 3

SIZE: 734 Bytes

HITS: 130

  1. class Page:
  2. def __init__(self, input_filename):
  3. self.input_filename = input_filename
  4. self.input_directory = '../input'
  5. self.output_directory = '../output'
  6. self.title = os.path.splitext(self.input_filename)[0]
  7. self.data = self.parse()
  8. self.output_filename = f'{self.title}.html'
  9. def parse(self):
  10. with open(os.path.join(self.input_directory, self.input_filename)) as input_file:
  11. print(f'parsing {input_file.name}')
  12. data = []
  13. for line in input_file:
  14. link = {}
  15. parser = NewsParser(line)
  16. link = parser.get_dict()
  17. data.append(link)
  18. return data

comments powered by Disqus