From 7ae814b49b678d9f7a20bae65b5433642f41313a Mon Sep 17 00:00:00 2001
From: Harold <8866033@gmail.com>
Date: Mon, 20 Apr 2026 16:05:34 +0800
Subject: [PATCH] =?UTF-8?q?=E7=8E=A9=E5=81=B6=E8=81=9A=E5=90=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
py/tests/test_人人电影.py | 41 +++++++++++++++++++++++++++++++++++++++
py/人人电影.py | 8 ++++----
py/奕搜.py | 2 +-
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/py/tests/test_人人电影.py b/py/tests/test_人人电影.py
index 0339acb..d042d81 100644
--- a/py/tests/test_人人电影.py
+++ b/py/tests/test_人人电影.py
@@ -102,6 +102,31 @@ class TestRenRenDianYingSpider(unittest.TestCase):
],
)
+ def test_parse_cards_uses_first_intro_link_instead_of_concatenating_multiple_detail_urls(self):
+ html = """
+
+ -
+
+
+ HD
+
+
+ """
+ self.assertEqual(
+ self.spider._parse_cards(html),
+ [
+ {
+ "vod_id": "/movie/2025/0814/51262.html",
+ "vod_name": "第一部",
+ "vod_pic": "https://www.rrdynb.com/poster.jpg",
+ "vod_remarks": "HD",
+ }
+ ],
+ )
+
@patch.object(Spider, "_request_html")
def test_category_content_builds_reference_url_and_page_payload(self, mock_request_html):
mock_request_html.return_value = """
@@ -123,6 +148,22 @@ class TestRenRenDianYingSpider(unittest.TestCase):
self.assertEqual(result["list"][0]["vod_name"], "分类影片")
self.assertNotIn("pagecount", result)
+ @patch.object(Spider, "_request_html")
+ def test_category_content_uses_plain_path_for_first_page(self, mock_request_html):
+ mock_request_html.return_value = """
+
+ -
+
+
+ HD
+
+
+ """
+ result = self.spider.categoryContent("movie/list_2", "1", False, {})
+ self.assertEqual(mock_request_html.call_args.args[0], "https://www.rrdynb.com/movie/list_2.html")
+ self.assertEqual(result["page"], 1)
+ self.assertEqual(result["list"][0]["vod_id"], "/movie/111.html")
+
@patch.object(Spider, "_request_html")
def test_search_content_builds_reference_url_and_cleans_highlight_title(self, mock_request_html):
mock_request_html.return_value = """
diff --git a/py/人人电影.py b/py/人人电影.py
index 90e85d7..ae10b1b 100644
--- a/py/人人电影.py
+++ b/py/人人电影.py
@@ -129,10 +129,10 @@ class Spider(BaseSpider):
items = []
seen = set()
for node in root.xpath("//*[@id='movielist']//li"):
- href = "".join(node.xpath(".//*[contains(@class,'intro')]//h2//a[1]/@href")).strip()
+ href = self._first_xpath_result(node, ".//*[contains(@class,'intro')]//h2//a/@href")
title = (
- "".join(node.xpath(".//*[contains(@class,'intro')]//h2//a[1]/@title")).strip()
- or "".join(node.xpath(".//*[contains(@class,'intro')]//h2//a[1]//text()")).strip()
+ self._first_xpath_result(node, ".//*[contains(@class,'intro')]//h2//a/@title")
+ or self._first_xpath_result(node, ".//*[contains(@class,'intro')]//h2//a//text()")
)
pic = (
self._first_xpath_result(node, ".//*[contains(@class,'pure-img')][1]/@data-original")
@@ -161,7 +161,7 @@ class Spider(BaseSpider):
class_path = str(tid or "").lstrip("/")
url = self._build_url(f"{class_path}_{page}.html")
items = self._parse_cards(self._request_html(url))
- return {"page": page, "limit": len(items), "total": page * 20 + len(items), "list": items}
+ return {"page": page, "limit": len(items), "total": page * 30 + len(items), "list": items}
def searchContent(self, key, quick, pg="1"):
page = int(pg)
diff --git a/py/奕搜.py b/py/奕搜.py
index e07cd76..3b12b06 100644
--- a/py/奕搜.py
+++ b/py/奕搜.py
@@ -105,7 +105,7 @@ class Spider(BaseSpider):
def categoryContent(self, tid, pg, filter, extend):
page = int(pg)
items = self._parse_list_boxes(self._request_html(self._build_url(f"/{tid}.html?page={page}")))
- return {"page": page, "limit": len(items) or 20, "total": page * (len(items) or 20), "list": items}
+ return {"page": page, "limit": len(items) or 20, "total": page * 30 + (len(items) or 20), "list": items}
def searchContent(self, key, quick, pg="1"):
page = int(pg)