From c79ec3007843bf263c3a89bd9ec4191afa5cdce8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 10 Oct 2021 02:40:21 +0200 Subject: [PATCH] links --- hypertext.py | 6 +++++- remote.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hypertext.py b/hypertext.py index 44abffd..42c5e49 100644 --- a/hypertext.py +++ b/hypertext.py @@ -1,4 +1,7 @@ import html.parser +import requests + +CHARSET = 'u8' class Parser(html.parser.HTMLParser): @@ -12,7 +15,8 @@ class Parser(html.parser.HTMLParser): [v for k, v in attributes if k == 'href']) -def get_links(hypertext): +def get_links(location): + hypertext = requests.get(location).content.decode(CHARSET) parser = Parser() parser.feed(hypertext) return parser.links diff --git a/remote.py b/remote.py index cb73ed0..27b28c0 100644 --- a/remote.py +++ b/remote.py @@ -36,8 +36,7 @@ class Remote: c = {} for architecture in self.architectures: location = os.path.join(self.location, DISTRIBUTION, architecture) - html = requests.get(location).content.decode(CHARSET) - links = sorted(hypertext.get_links(html)) + links = sorted(hypertext.get_links(location)) archives = [link for link in links if link.endswith(ARCHIVE)] archive = archives[-1]