Refactor HTTP common code (#207)
- move to common/http.py, - make fetch_url return a Response.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
from common import http
|
||||
from common import endoflife
|
||||
|
||||
"""Fetch HAProxy versions with their dates from https://www.haproxy.org/.
|
||||
@@ -14,8 +15,8 @@ VERSION_REGEX = r"^(\d{4})\/(\d{2})\/(\d{2})\s+:\s+(\d+\.\d+\.\d.?)$"
|
||||
def fetch_cycles():
|
||||
cycles = []
|
||||
|
||||
response = endoflife.fetch_url('https://www.haproxy.org/download/')
|
||||
soup = BeautifulSoup(response, features="html5lib")
|
||||
response = http.fetch_url('https://www.haproxy.org/download/')
|
||||
soup = BeautifulSoup(response.text, features="html5lib")
|
||||
for link in soup.select("a"):
|
||||
m = re.match(CYCLE_REGEX, link.attrs["href"])
|
||||
if m:
|
||||
@@ -32,7 +33,7 @@ def fetch_releases(cycles):
|
||||
releases = {}
|
||||
|
||||
urls = [f"https://www.haproxy.org/download/{cycle}/src/CHANGELOG" for cycle in cycles]
|
||||
for response in endoflife.fetch_urls(urls):
|
||||
for response in http.fetch_urls(urls):
|
||||
for line in response.text.split('\n'):
|
||||
m = re.match(VERSION_REGEX, line)
|
||||
if m:
|
||||
|
||||
Reference in New Issue
Block a user