Files
endoflife-date-release-data/src/oracle-jdk.py
Marc Wrobel 9cf243a10e Fix scripts requiring rendering pages with javascript (#310)
Replace request_html by playwright, as request_html, as it is [not maintained anymore](https://pypi.org/project/requests-html/) and scripts using it, such as artifactory.py, started to fail.
2024-02-16 23:13:42 +01:00

23 lines
923 B
Python

from bs4 import BeautifulSoup
from common import dates, http, releasedata
"""Fetch Java versions from https://www.java.com/releases/.
This script is using requests-html because the page needs JavaScript to render correctly."""
with releasedata.ProductData("oracle-jdk") as product_data:
content = http.fetch_javascript_url('https://www.java.com/releases/')
soup = BeautifulSoup(content, 'html.parser')
previous_date = None
for row in soup.select('#released tr'):
version_cell = row.select_one('td.anchor')
if version_cell:
version = version_cell.attrs['id']
date_str = row.select('td')[1].text
date = dates.parse_date(date_str) if date_str else previous_date
product_data.declare_version(version, date)
previous_date = date
product_data.remove_version('1.0_alpha') # the only version we don't want, a regex is not needed