links
This commit is contained in:
parent
e45e9cb408
commit
c79ec30078
2 changed files with 6 additions and 3 deletions
|
@ -1,4 +1,7 @@
|
||||||
import html.parser
|
import html.parser
|
||||||
|
import requests
|
||||||
|
|
||||||
|
CHARSET = 'u8'
|
||||||
|
|
||||||
|
|
||||||
class Parser(html.parser.HTMLParser):
|
class Parser(html.parser.HTMLParser):
|
||||||
|
@ -12,7 +15,8 @@ class Parser(html.parser.HTMLParser):
|
||||||
[v for k, v in attributes if k == 'href'])
|
[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 = Parser()
|
||||||
parser.feed(hypertext)
|
parser.feed(hypertext)
|
||||||
return parser.links
|
return parser.links
|
||||||
|
|
|
@ -36,8 +36,7 @@ class Remote:
|
||||||
c = {}
|
c = {}
|
||||||
for architecture in self.architectures:
|
for architecture in self.architectures:
|
||||||
location = os.path.join(self.location, DISTRIBUTION, architecture)
|
location = os.path.join(self.location, DISTRIBUTION, architecture)
|
||||||
html = requests.get(location).content.decode(CHARSET)
|
links = sorted(hypertext.get_links(location))
|
||||||
links = sorted(hypertext.get_links(html))
|
|
||||||
archives = [link for link in links
|
archives = [link for link in links
|
||||||
if link.endswith(ARCHIVE)]
|
if link.endswith(ARCHIVE)]
|
||||||
archive = archives[-1]
|
archive = archives[-1]
|
||||||
|
|
Loading…
Reference in a new issue