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.
This commit is contained in:
Marc Wrobel
2024-02-16 22:51:21 +01:00
parent 1175756d11
commit 9cf243a10e
9 changed files with 69 additions and 48 deletions

View File

@@ -1,15 +1,15 @@
from common import dates, releasedata
from requests_html import HTMLSession
from bs4 import BeautifulSoup
from common import dates, http, releasedata
"""Fetches Confluence versions from www.atlassian.com.
Note that requests_html is used because JavaScript is needed to render the page."""
with releasedata.ProductData("confluence") as product_data:
r = HTMLSession().get("https://www.atlassian.com/software/confluence/download-archives")
r.html.render(sleep=1, scrolldown=3)
content = http.fetch_javascript_url("https://www.atlassian.com/software/confluence/download-archives")
soup = BeautifulSoup(content, 'html.parser')
for version_block in r.html.find('.versions-list'):
version = version_block.find('a.product-versions', first=True).attrs['data-version']
date = dates.parse_date(version_block.find('.release-date', first=True).text)
for version_block in soup.select('.versions-list'):
version = version_block.select_one('a.product-versions').attrs['data-version']
date = dates.parse_date(version_block.select_one('.release-date').text)
product_data.declare_version(version, date)