From 8e65564fb8992a23dc78c9cf5273d1f71faf8f0f Mon Sep 17 00:00:00 2001 From: xgitc Date: Wed, 10 Dec 2025 16:12:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E4=B8=8D=E5=90=8C=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84gazelle=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适配隐藏了URL中“.php”的站点;适配下一页按钮title为“下一页”或“Next”的站点。 --- app/modules/indexer/parser/gazelle.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/modules/indexer/parser/gazelle.py b/app/modules/indexer/parser/gazelle.py index 71508589..eca24939 100644 --- a/app/modules/indexer/parser/gazelle.py +++ b/app/modules/indexer/parser/gazelle.py @@ -15,9 +15,9 @@ class GazelleSiteUserInfo(SiteParserBase): html_text = self._prepare_html_text(html_text) html = etree.HTML(html_text) try: - tmps = html.xpath('//a[contains(@href, "user.php?id=")]') + tmps = html.xpath('//a[contains(@href, "user.php?id=") or contains(@href, "user?id=")]') if tmps: - user_id_match = re.search(r"user.php\?id=(\d+)", tmps[0].attrib['href']) + user_id_match = re.search(r"user(?:\.php)?\?id=(\d+)", tmps[0].attrib['href']) if user_id_match and user_id_match.group().strip(): self.userid = user_id_match.group(1) self._torrent_seeding_page = f"torrents.php?type=seeding&userid={self.userid}" @@ -42,13 +42,13 @@ class GazelleSiteUserInfo(SiteParserBase): self.ratio = 0.0 if self.download <= 0.0 else round(self.upload / self.download, 3) - tmps = html.xpath('//a[contains(@href, "bonus.php")]/@data-tooltip') + tmps = html.xpath('//a[contains(@href, "bonus")]/@data-tooltip') if tmps: bonus_match = re.search(r"([\d,.]+)", tmps[0]) if bonus_match and bonus_match.group(1).strip(): self.bonus = StringUtils.str_float(bonus_match.group(1)) else: - tmps = html.xpath('//a[contains(@href, "bonus.php")]') + tmps = html.xpath('//a[contains(@href, "bonus")]') if tmps: bonus_text = tmps[0].xpath("string(.)") bonus_match = re.search(r"([\d,.]+)", bonus_text) @@ -142,7 +142,7 @@ class GazelleSiteUserInfo(SiteParserBase): # 是否存在下页数据 next_page = None - next_page_text = html.xpath('//a[contains(.//text(), "Next") or contains(.//text(), "下一页")]/@href') + next_page_text = html.xpath('//a[contains(.//text(), "Next") or contains(.//text(), "下一页") or contains(@title, "下一页") or contains(@title, "Next")]/@href') if next_page_text: next_page = next_page_text[-1].strip() finally: