Skip to content

Commit

Permalink
Fix for scraping Forge version
Browse files Browse the repository at this point in the history
  • Loading branch information
macarooni-man committed Feb 4, 2025
1 parent a155f35 commit d3090b0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions source/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1741,12 +1741,19 @@ def latest_version(name, url):
reqs = requests.get(url, timeout=timeout)
soup = BeautifulSoup(reqs.text, 'html.parser')

# Get side panel latest version
li = soup.find('li', 'li-version-list')
version_list = []

# Get side panel versions
li_list = soup.find_all('li', 'li-version-list')
for li in li_list:
for sub_li in li.find_all('li'):
version = sub_li.text.strip()
url = url.rsplit('/', 1)[0] + f'/index_{version}.html'
version_list.append((version, url))

# Get the first entry from the side panel versions
try:
new_url = url.rsplit('/', 1)[0] + '/' + li.find_all('a')[-1].get('href')
reqs = requests.get(new_url, timeout=timeout)
reqs = requests.get(version_list[0][-1], timeout=timeout)
soup = BeautifulSoup(reqs.text, 'html.parser')
except:
pass
Expand Down

0 comments on commit d3090b0

Please sign in to comment.