[cos] Workaround for broken table for cos-105
This commit is contained in:
16
src/cos.py
16
src/cos.py
@@ -15,7 +15,7 @@ def fetch_all_milestones():
|
|||||||
soup = BeautifulSoup(response, features="html5lib")
|
soup = BeautifulSoup(response, features="html5lib")
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Retrying Request, got error: " + e)
|
print("Retrying Request, got error: " + str(e))
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
raise Exception("Failed to fetch COS milestones")
|
raise Exception("Failed to fetch COS milestones")
|
||||||
@@ -43,6 +43,11 @@ def parse_soup_for_versions(soup):
|
|||||||
""" Parse the soup """
|
""" Parse the soup """
|
||||||
versions = {}
|
versions = {}
|
||||||
for article in soup.find_all('article', class_='devsite-article'):
|
for article in soup.find_all('article', class_='devsite-article'):
|
||||||
|
def parse_date(d):
|
||||||
|
# If the date begins with a >3 letter month name, trim it to just 3 letters
|
||||||
|
# Strip out the Date: section from the start
|
||||||
|
d = re.sub(r'(?:Date\: )?(\w{3})(?:\w{1,4})? (\d{1,2}), (\d{4})', r'\1 \2, \3', d)
|
||||||
|
return datetime.strptime(d, date_format).strftime('%Y-%m-%d')
|
||||||
# h2 contains the date, which we parse
|
# h2 contains the date, which we parse
|
||||||
for heading in article.find_all(['h2', 'h3']):
|
for heading in article.find_all(['h2', 'h3']):
|
||||||
version = heading.get('data-text')
|
version = heading.get('data-text')
|
||||||
@@ -56,10 +61,11 @@ def parse_soup_for_versions(soup):
|
|||||||
except:
|
except:
|
||||||
# In some older releases, it is mentioned as Date: [Date] in the text
|
# In some older releases, it is mentioned as Date: [Date] in the text
|
||||||
d = heading.find_next('i').text
|
d = heading.find_next('i').text
|
||||||
# If the date begins with a 4 letter month name, trim it to just 3 letters
|
try:
|
||||||
# Strip out the Date: section from the start
|
date = parse_date(d)
|
||||||
d = re.sub(r'(?:Date\: )?(\w{3})(?:\w{1})? (\d{1,2}), (\d{4})', r'\1 \2, \3', d)
|
except ValueError:
|
||||||
date = datetime.strptime(d, date_format).strftime('%Y-%m-%d')
|
d = heading.find_previous('h2').get('data-text')
|
||||||
|
date = parse_date(d)
|
||||||
versions[version] = date
|
versions[version] = date
|
||||||
|
|
||||||
return versions
|
return versions
|
||||||
|
|||||||
Reference in New Issue
Block a user