From 377fb9138c4040b0606092950174b210d11a928c Mon Sep 17 00:00:00 2001 From: Septatrix <24257556+Septatrix@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:45:47 +0100 Subject: [PATCH] Fix parsing of package id Previously the order id was extracted which does not match the cID --- certbotstratoapi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/certbotstratoapi.py b/certbotstratoapi.py index cbf9e22..1dd9d5e 100644 --- a/certbotstratoapi.py +++ b/certbotstratoapi.py @@ -146,10 +146,15 @@ def get_package_id(self) -> None: 'node': 'kds_CustomerEntryPage', }) soup = BeautifulSoup(request.text, 'html.parser') - package_element = soup.select_one(f'div.package-information:-soup-contains("{self.second_level_domain_name}")') - if package_element is not None: - if package_element.has_attr('id') and package_element['id'].startswith('package_information_'): - self.package_id = package_element['id'][20:] # remove prefix 'package_information_' + package_anchor = soup.select_one( + '#package_list > tbody >' + f' tr:has(.package-information:-soup-contains("{self.second_level_domain_name}"))' + ' .jss_with_own_packagename a' + ) + if package_anchor: + if package_anchor.has_attr('href'): + link_target = urllib.parse.urlparse(package_anchor["href"]) + self.package_id = urllib.parse.parse_qs(link_target.query)["cID"][0] print(f'INFO: strato package id (cID): {self.package_id}') return else: