parsehub 2.4.0__tar.gz → 2.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {parsehub-2.4.0/src/parsehub.egg-info → parsehub-2.4.2}/PKG-INFO +23 -22
  2. {parsehub-2.4.0 → parsehub-2.4.2}/README.md +1 -0
  3. {parsehub-2.4.0 → parsehub-2.4.2}/pyproject.toml +25 -25
  4. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/__init__.py +1 -0
  5. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/instagram.py +9 -7
  6. parsehub-2.4.2/src/parsehub/parsers/parser/jandan.py +35 -0
  7. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/kuaishou.py +1 -0
  8. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/instagram.py +1 -2
  9. parsehub-2.4.2/src/parsehub/provider_api/jandan.py +104 -0
  10. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/wxchannels.py +1 -3
  11. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/platform.py +1 -0
  12. {parsehub-2.4.0 → parsehub-2.4.2/src/parsehub.egg-info}/PKG-INFO +23 -22
  13. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub.egg-info/SOURCES.txt +3 -5
  14. parsehub-2.4.2/src/parsehub.egg-info/requires.txt +27 -0
  15. {parsehub-2.4.0 → parsehub-2.4.2}/test/test_core_offline.py +7 -335
  16. parsehub-2.4.0/src/parsehub.egg-info/requires.txt +0 -27
  17. parsehub-2.4.0/test/test_bilibili_music_offline.py +0 -127
  18. parsehub-2.4.0/test/test_bilibili_offline.py +0 -63
  19. parsehub-2.4.0/test/test_instagram_duration_offline.py +0 -134
  20. parsehub-2.4.0/test/test_zuiyou_duration_offline.py +0 -69
  21. {parsehub-2.4.0 → parsehub-2.4.2}/LICENSE +0 -0
  22. {parsehub-2.4.0 → parsehub-2.4.2}/setup.cfg +0 -0
  23. {parsehub-2.4.0 → parsehub-2.4.2}/src/__init__.py +0 -0
  24. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/__init__.py +0 -0
  25. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/cli.py +0 -0
  26. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/cli_config.py +0 -0
  27. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/config/__init__.py +0 -0
  28. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/config/config.py +0 -0
  29. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/errors.py +0 -0
  30. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/__init__.py +0 -0
  31. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/base/__init__.py +0 -0
  32. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/base/base.py +0 -0
  33. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/base/ytdlp.py +0 -0
  34. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/bangumi.py +0 -0
  35. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/bilibili.py +0 -0
  36. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/coolapk.py +0 -0
  37. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/douban.py +0 -0
  38. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/douyin.py +0 -0
  39. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/facebook.py +0 -0
  40. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/medium.py +0 -0
  41. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/pipix.py +0 -0
  42. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/snapchat.py +0 -0
  43. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/threads.py +0 -0
  44. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/tieba.py +0 -0
  45. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/tiktok.py +0 -0
  46. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/toutiao.py +0 -0
  47. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/twitter.py +0 -0
  48. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/weibo.py +0 -0
  49. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/weixin.py +0 -0
  50. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/wxchannels.py +0 -0
  51. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/xhs.py +0 -0
  52. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/xiaoheihe.py +0 -0
  53. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/youtube.py +0 -0
  54. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/zhihu.py +0 -0
  55. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/parsers/parser/zuiyou.py +0 -0
  56. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/__init__.py +0 -0
  57. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/bangumi.py +0 -0
  58. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/bilibili.py +0 -0
  59. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/coolapk.py +0 -0
  60. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/douban.py +0 -0
  61. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/douyin.py +0 -0
  62. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/kuaishou.py +0 -0
  63. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/medium.py +0 -0
  64. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/pipix.py +0 -0
  65. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/threads.py +0 -0
  66. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/tieba.py +0 -0
  67. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/tiktok.py +0 -0
  68. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/toutiao.py +0 -0
  69. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/twitter.py +0 -0
  70. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/weibo.py +0 -0
  71. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/weixin.py +0 -0
  72. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/xhs.py +0 -0
  73. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/xiaoheihe.py +0 -0
  74. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/zhihu.py +0 -0
  75. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/provider_api/zuiyou.py +0 -0
  76. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/__init__.py +0 -0
  77. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/callback.py +0 -0
  78. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/media_file.py +0 -0
  79. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/media_ref.py +0 -0
  80. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/post.py +0 -0
  81. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/types/result.py +0 -0
  82. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/utils/downloader.py +0 -0
  83. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/utils/fallback.py +0 -0
  84. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/utils/helpers.py +0 -0
  85. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub/utils/media_info.py +0 -0
  86. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub.egg-info/dependency_links.txt +0 -0
  87. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub.egg-info/entry_points.txt +0 -0
  88. {parsehub-2.4.0 → parsehub-2.4.2}/src/parsehub.egg-info/top_level.txt +0 -0
  89. {parsehub-2.4.0 → parsehub-2.4.2}/test/test_cli.py +0 -0
  90. {parsehub-2.4.0 → parsehub-2.4.2}/test/test_cli_config.py +0 -0
  91. {parsehub-2.4.0 → parsehub-2.4.2}/test/test_downloader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: parsehub
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: 轻量、异步、开箱即用的社交媒体聚合解析库
5
5
  Author-email: 梓澪 <zilingmio@gmail.com>
6
6
  License: MIT
@@ -15,32 +15,32 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
15
  Requires-Python: >=3.12.0
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: aiofiles>=23.2
19
- Requires-Dist: beautifulsoup4>=4.12.3
20
- Requires-Dist: loguru>=0.6.0
18
+ Requires-Dist: aiofiles>=25.1.0
19
+ Requires-Dist: beautifulsoup4>=4.15.0
20
+ Requires-Dist: loguru>=0.7.3
21
21
  Requires-Dist: pydub>=0.25.1
22
- Requires-Dist: python-dotenv>=1.0.1
23
- Requires-Dist: tenacity>=8.5.0
24
- Requires-Dist: urlextract>=1.9.0
25
- Requires-Dist: yt-dlp[default]>=2026.10.26.220202.dev0
26
- Requires-Dist: lxml>=5.3.0
27
- Requires-Dist: pydantic>=1.10.19
28
- Requires-Dist: markdownify>=1.1.0
29
- Requires-Dist: markdown>=3.7
30
- Requires-Dist: json5>=0.12
31
- Requires-Dist: requests
32
- Requires-Dist: httpx[socks]>=0.24.1
33
- Requires-Dist: pillow>=12.1.0
34
- Requires-Dist: python-slugify[unidecode]>=8.0.4
35
- Requires-Dist: opencv-python-headless>=4.13.0.92
36
- Requires-Dist: cryptography>=49.0.0
22
+ Requires-Dist: python-dotenv>=1.2.4
23
+ Requires-Dist: tenacity>=9.2.1
24
+ Requires-Dist: urlextract>=1.10.0
25
+ Requires-Dist: yt-dlp[default]>=2026.11.4.232659.dev0
26
+ Requires-Dist: lxml>=6.1.3
27
+ Requires-Dist: pydantic>=2.14.3
28
+ Requires-Dist: markdownify>=1.2.3
29
+ Requires-Dist: markdown>=3.11.3
30
+ Requires-Dist: json5>=0.17.3
31
+ Requires-Dist: requests>=2.34.2
32
+ Requires-Dist: httpx[socks]>=0.28.1
33
+ Requires-Dist: pillow>=13.0.0
34
+ Requires-Dist: python-slugify[unidecode]>=9.1.3
35
+ Requires-Dist: opencv-python-headless>=5.0.0.93
36
+ Requires-Dist: cryptography>=50.0.2
37
37
  Requires-Dist: gmssl>=3.2.2
38
38
  Requires-Dist: signerpy>=0.12.0
39
- Requires-Dist: curl-cffi>=0.13
39
+ Requires-Dist: curl-cffi>=0.17.0
40
40
  Requires-Dist: xhshow>=0.2.0
41
41
  Provides-Extra: cli
42
- Requires-Dist: argcomplete>=3.6.3; extra == "cli"
43
- Requires-Dist: platformdirs>=4.5.1; extra == "cli"
42
+ Requires-Dist: argcomplete>=3.7.2; extra == "cli"
43
+ Requires-Dist: platformdirs>=4.14.5; extra == "cli"
44
44
  Dynamic: license-file
45
45
 
46
46
  <div align="center">
@@ -101,6 +101,7 @@ Dynamic: license-file
101
101
  | **Bangumi** | | ✅ | 💬 条目讨论, 日志, 小组话题 |
102
102
  | **今日头条** | ✅ | ✅ | 📰 文章, 微头条 |
103
103
  | **Medium** | ✅ | ✅ | 📰 文章 |
104
+ | **煎蛋** | | ✅ | 📰 文章, 💬 话题 |
104
105
 
105
106
  ## 📦 安装
106
107
 
@@ -56,6 +56,7 @@
56
56
  | **Bangumi** | | ✅ | 💬 条目讨论, 日志, 小组话题 |
57
57
  | **今日头条** | ✅ | ✅ | 📰 文章, 微头条 |
58
58
  | **Medium** | ✅ | ✅ | 📰 文章 |
59
+ | **煎蛋** | | ✅ | 📰 文章, 💬 话题 |
59
60
 
60
61
  ## 📦 安装
61
62
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "parsehub"
3
- version = "2.4.0"
3
+ version = "2.4.2"
4
4
  description = "轻量、异步、开箱即用的社交媒体聚合解析库"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12.0"
@@ -18,28 +18,28 @@ classifiers = [
18
18
  ]
19
19
 
20
20
  dependencies = [
21
- "aiofiles>=23.2",
22
- "beautifulsoup4>=4.12.3",
23
- "loguru>=0.6.0",
21
+ "aiofiles>=25.1.0",
22
+ "beautifulsoup4>=4.15.0",
23
+ "loguru>=0.7.3",
24
24
  "pydub>=0.25.1",
25
- "python-dotenv>=1.0.1",
26
- "tenacity>=8.5.0",
27
- "urlextract>=1.9.0",
28
- "yt-dlp[default]>=2026.10.26.220202.dev0",
29
- "lxml>=5.3.0",
30
- "pydantic>=1.10.19",
31
- "markdownify>=1.1.0",
32
- "markdown>=3.7",
33
- "json5>=0.12",
34
- "requests",
35
- "httpx[socks]>=0.24.1",
36
- "pillow>=12.1.0",
37
- "python-slugify[unidecode]>=8.0.4",
38
- "opencv-python-headless>=4.13.0.92",
39
- "cryptography>=49.0.0",
25
+ "python-dotenv>=1.2.4",
26
+ "tenacity>=9.2.1",
27
+ "urlextract>=1.10.0",
28
+ "yt-dlp[default]>=2026.11.4.232659.dev0",
29
+ "lxml>=6.1.3",
30
+ "pydantic>=2.14.3",
31
+ "markdownify>=1.2.3",
32
+ "markdown>=3.11.3",
33
+ "json5>=0.17.3",
34
+ "requests>=2.34.2",
35
+ "httpx[socks]>=0.28.1",
36
+ "pillow>=13.0.0",
37
+ "python-slugify[unidecode]>=9.1.3",
38
+ "opencv-python-headless>=5.0.0.93",
39
+ "cryptography>=50.0.2",
40
40
  "gmssl>=3.2.2",
41
41
  "signerpy>=0.12.0",
42
- "curl-cffi>=0.13",
42
+ "curl-cffi>=0.17.0",
43
43
  "xhshow>=0.2.0",
44
44
  ]
45
45
 
@@ -49,15 +49,15 @@ ph = "parsehub.cli:main"
49
49
 
50
50
  [project.optional-dependencies]
51
51
  cli = [
52
- "argcomplete>=3.6.3",
53
- "platformdirs>=4.5.1",
52
+ "argcomplete>=3.7.2",
53
+ "platformdirs>=4.14.5",
54
54
  ]
55
55
 
56
56
  [dependency-groups]
57
57
  dev = [
58
- "mypy>=2.1.0",
59
- "pytest>=9.0.3",
60
- "ruff>=0.14.14",
58
+ "mypy>=2.4.1",
59
+ "pytest>=9.2.0",
60
+ "ruff>=0.17.4",
61
61
  ]
62
62
 
63
63
  [tool.hatch.build.targets.wheel]
@@ -6,6 +6,7 @@ from .douban import *
6
6
  from .douyin import *
7
7
  from .facebook import *
8
8
  from .instagram import *
9
+ from .jandan import *
9
10
  from .medium import *
10
11
  from .threads import *
11
12
  from .tieba import *
@@ -66,7 +66,7 @@ class InstagramParser(BaseParser):
66
66
  except ParseError as e:
67
67
  logger.warning(f"Instagram yt-dlp 解析失败, 使用直链视频: {e}")
68
68
  else:
69
- return YtVideoParseResult(
69
+ return InstagramYtVideoParseResult(
70
70
  dl=info,
71
71
  title=post.title,
72
72
  content=post.caption,
@@ -98,12 +98,8 @@ class InstagramParser(BaseParser):
98
98
  async def _parse(self, shortcode: str) -> InstagramPost:
99
99
  stages: list[FallbackStage[InstagramPost]] = [FallbackStage("匿名", lambda: self._fetch(shortcode))]
100
100
  if self.cookie.get_value():
101
- stages.append(
102
- FallbackStage("cookie", lambda: self._fetch(shortcode, self.cookie), cookie=True)
103
- )
104
- return await self._fallback(
105
- *stages, stop=lambda e: not isinstance(e.__cause__, InstagramRestrictedError)
106
- )
101
+ stages.append(FallbackStage("cookie", lambda: self._fetch(shortcode, self.cookie), cookie=True))
102
+ return await self._fallback(*stages, stop=lambda e: not isinstance(e.__cause__, InstagramRestrictedError))
107
103
 
108
104
  async def _fetch(self, shortcode: str, cookie: SecretCookie | None = None) -> InstagramPost:
109
105
  api = InstagramAPI(proxy=self.proxy, cookie=cookie.get_value() if cookie else None, timeout=30)
@@ -127,4 +123,10 @@ class InstagramYtParse(YtParser, register=False):
127
123
  pass
128
124
 
129
125
 
126
+ class InstagramYtVideoParseResult(YtVideoParseResult):
127
+ @property
128
+ def cli_args(self) -> list[str]:
129
+ return [*super().cli_args, "-S", "vcodec:h264"]
130
+
131
+
130
132
  __all__ = ["InstagramParser"]
@@ -0,0 +1,35 @@
1
+ from pathlib import PurePosixPath
2
+ from urllib.parse import urlsplit
3
+
4
+ from ...provider_api.jandan import Jandan, JandanError
5
+ from ...types import AniRef, ImageRef, ParseError, Platform, RichTextParseResult
6
+ from ..base.base import BaseParser
7
+
8
+
9
+ class JandanParser(BaseParser):
10
+ __platform__ = Platform.JANDAN
11
+ __supported_type__ = ["图文"]
12
+ __match__ = r"^(http(s)?://)?jandan\.net/(t|p)/\d+"
13
+
14
+ @staticmethod
15
+ def _ref(url: str) -> ImageRef | AniRef:
16
+ """正文里的动图也是 <img>; 扩展名取自 URL."""
17
+ suffix = PurePosixPath(urlsplit(url).path).suffix.lstrip(".").lower()
18
+ if suffix == "gif":
19
+ return AniRef(url=url)
20
+ return ImageRef(url=url, ext=suffix) if suffix else ImageRef(url=url)
21
+
22
+ async def _do_parse(self, raw_url: str) -> RichTextParseResult:
23
+ try:
24
+ post = await Jandan(proxy=self.proxy).parse(raw_url)
25
+ except JandanError as e:
26
+ raise ParseError(f"煎蛋解析失败: {e}") from e
27
+
28
+ return RichTextParseResult(
29
+ title=post.title,
30
+ media=[self._ref(url) for url in post.images],
31
+ markdown_content=post.markdown_content,
32
+ )
33
+
34
+
35
+ __all__ = ["JandanParser"]
@@ -46,6 +46,7 @@ class KuaiShouParser(BaseParser):
46
46
  if (
47
47
  ksp.page_type == "VIDEO" or "/short-video/" in raw_url
48
48
  ): # 地区风控导致获取到的 page_type 可能为 ATLAS 但实际为视频
49
+
49
50
  async def parse_html() -> VideoParseResult:
50
51
  content = ksp.get_title_content()
51
52
  video = ksp.get_real_video_url()
@@ -131,8 +131,7 @@ class InstagramAPI:
131
131
  ) -> InstagramPost:
132
132
  """用 embed 补齐 v1 / GraphQL 缺失的视频直链和时长。"""
133
133
  if not any(
134
- (post.type is InstagramMediaType.VIDEO or item.is_video)
135
- and (not item.video_url or item.duration <= 0)
134
+ (post.type is InstagramMediaType.VIDEO or item.is_video) and (not item.video_url or item.duration <= 0)
136
135
  for item in post.media
137
136
  ):
138
137
  return post
@@ -0,0 +1,104 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from dataclasses import dataclass, field
5
+ from typing import Any
6
+ from urllib.parse import urljoin
7
+
8
+ import httpx
9
+ from bs4 import BeautifulSoup
10
+ from markdownify import MarkdownConverter
11
+
12
+ from ..errors import ContentUnavailableError
13
+ from ..utils.helpers import UA
14
+
15
+ _POST_NO_RE = re.compile(r"No\.\s*\d+")
16
+
17
+
18
+ @dataclass
19
+ class JandanPost:
20
+ """煎蛋帖子的解析结果
21
+
22
+ Attributes:
23
+ title: 标题
24
+ markdown_content: markdown 正文
25
+ images: 正文内的图片地址
26
+ """
27
+
28
+ title: str
29
+ markdown_content: str
30
+ images: list[str] = field(default_factory=list)
31
+
32
+
33
+ class Jandan:
34
+ def __init__(self, proxy: str | None = None):
35
+ self.proxy = proxy
36
+
37
+ async def parse(self, url: str) -> JandanPost:
38
+ async with httpx.AsyncClient(proxy=self.proxy, timeout=30, headers={"User-Agent": UA}) as client:
39
+ response = await client.get(url)
40
+ if response.status_code == 404:
41
+ raise ContentUnavailableError("煎蛋内容不存在或已删除")
42
+ if not 200 <= response.status_code < 300:
43
+ raise JandanError(f"HTTP {response.status_code}")
44
+ return self._parse_html(response.text, str(response.url))
45
+
46
+ @staticmethod
47
+ def _parse_html(html: str, page_url: str) -> JandanPost:
48
+ soup = BeautifulSoup(html, "lxml")
49
+ content = soup.select_one(".post-content")
50
+ if content is None:
51
+ raise JandanError("未找到煎蛋正文")
52
+
53
+ heading = soup.find("h1")
54
+ for a in content.find_all("a", href=True):
55
+ a["href"] = urljoin(page_url, str(a["href"]))
56
+ converter = _JandanMarkdownConverter(page_url)
57
+ markdown_content = converter.convert(str(content)).strip()
58
+ return JandanPost(
59
+ title=_compose_title(
60
+ heading.get_text(strip=True) if heading else "",
61
+ _first_line(content.get_text("\n", strip=True)),
62
+ ),
63
+ markdown_content=markdown_content,
64
+ images=converter.images,
65
+ )
66
+
67
+
68
+ def _first_line(text: str, limit: int = 80) -> str:
69
+ line = next((line for line in text.splitlines() if line.strip()), "")
70
+ return " ".join(line.split())[:limit]
71
+
72
+
73
+ def _compose_title(heading: str, first_line: str) -> str:
74
+ """话题帖的标题只是 "No.6209188", 这时用正文首行代替."""
75
+ heading = " ".join(heading.split())
76
+ if heading and not _POST_NO_RE.fullmatch(heading):
77
+ return heading
78
+ return first_line or heading
79
+
80
+
81
+ class _JandanMarkdownConverter(MarkdownConverter):
82
+ """把正文 HTML 转为 markdown 并收集图片地址."""
83
+
84
+ def __init__(self, page_url: str) -> None:
85
+ super().__init__(heading_style="ATX")
86
+ self.page_url = page_url
87
+ self.images: list[str] = []
88
+
89
+ def convert_img(self, el: Any, text: Any, parent_tags: Any) -> str:
90
+ alt = el.attrs.get("alt") or ""
91
+ source = el.attrs.get("src") or ""
92
+ url = urljoin(self.page_url, source) if source else ""
93
+ if not url:
94
+ return alt
95
+ if url not in self.images:
96
+ self.images.append(url)
97
+ return f"![{alt}]({url})"
98
+
99
+
100
+ class JandanError(Exception):
101
+ pass
102
+
103
+
104
+ __all__ = ["Jandan", "JandanError", "JandanPost"]
@@ -95,9 +95,7 @@ class WXChannels:
95
95
 
96
96
  feed_data = feed_result.get("data") or {}
97
97
  feed_error = feed_data.get("errMsg") or {}
98
- error_text = " ".join(
99
- _strip_html(str(feed_error.get(key) or "")) for key in ("title", "content")
100
- ).strip()
98
+ error_text = " ".join(_strip_html(str(feed_error.get(key) or "")) for key in ("title", "content")).strip()
101
99
  if feed_result.get("errCode") != 0:
102
100
  message = feed_result.get("errMsg") or "微信视频号解析失败"
103
101
  raise WXChannelsError(str(message))
@@ -14,6 +14,7 @@ class Platform(Enum):
14
14
  MEDIUM = ("medium", "Medium")
15
15
  FACEBOOK = ("facebook", "Facebook")
16
16
  INSTAGRAM = ("instagram", "Instagram")
17
+ JANDAN = ("jandan", "煎蛋")
17
18
  KUAISHOU = ("kuaishou", "快手")
18
19
  PIPIX = ("pipix", "皮皮虾")
19
20
  THREADS = ("threads", "Threads")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: parsehub
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: 轻量、异步、开箱即用的社交媒体聚合解析库
5
5
  Author-email: 梓澪 <zilingmio@gmail.com>
6
6
  License: MIT
@@ -15,32 +15,32 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
15
  Requires-Python: >=3.12.0
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: aiofiles>=23.2
19
- Requires-Dist: beautifulsoup4>=4.12.3
20
- Requires-Dist: loguru>=0.6.0
18
+ Requires-Dist: aiofiles>=25.1.0
19
+ Requires-Dist: beautifulsoup4>=4.15.0
20
+ Requires-Dist: loguru>=0.7.3
21
21
  Requires-Dist: pydub>=0.25.1
22
- Requires-Dist: python-dotenv>=1.0.1
23
- Requires-Dist: tenacity>=8.5.0
24
- Requires-Dist: urlextract>=1.9.0
25
- Requires-Dist: yt-dlp[default]>=2026.10.26.220202.dev0
26
- Requires-Dist: lxml>=5.3.0
27
- Requires-Dist: pydantic>=1.10.19
28
- Requires-Dist: markdownify>=1.1.0
29
- Requires-Dist: markdown>=3.7
30
- Requires-Dist: json5>=0.12
31
- Requires-Dist: requests
32
- Requires-Dist: httpx[socks]>=0.24.1
33
- Requires-Dist: pillow>=12.1.0
34
- Requires-Dist: python-slugify[unidecode]>=8.0.4
35
- Requires-Dist: opencv-python-headless>=4.13.0.92
36
- Requires-Dist: cryptography>=49.0.0
22
+ Requires-Dist: python-dotenv>=1.2.4
23
+ Requires-Dist: tenacity>=9.2.1
24
+ Requires-Dist: urlextract>=1.10.0
25
+ Requires-Dist: yt-dlp[default]>=2026.11.4.232659.dev0
26
+ Requires-Dist: lxml>=6.1.3
27
+ Requires-Dist: pydantic>=2.14.3
28
+ Requires-Dist: markdownify>=1.2.3
29
+ Requires-Dist: markdown>=3.11.3
30
+ Requires-Dist: json5>=0.17.3
31
+ Requires-Dist: requests>=2.34.2
32
+ Requires-Dist: httpx[socks]>=0.28.1
33
+ Requires-Dist: pillow>=13.0.0
34
+ Requires-Dist: python-slugify[unidecode]>=9.1.3
35
+ Requires-Dist: opencv-python-headless>=5.0.0.93
36
+ Requires-Dist: cryptography>=50.0.2
37
37
  Requires-Dist: gmssl>=3.2.2
38
38
  Requires-Dist: signerpy>=0.12.0
39
- Requires-Dist: curl-cffi>=0.13
39
+ Requires-Dist: curl-cffi>=0.17.0
40
40
  Requires-Dist: xhshow>=0.2.0
41
41
  Provides-Extra: cli
42
- Requires-Dist: argcomplete>=3.6.3; extra == "cli"
43
- Requires-Dist: platformdirs>=4.5.1; extra == "cli"
42
+ Requires-Dist: argcomplete>=3.7.2; extra == "cli"
43
+ Requires-Dist: platformdirs>=4.14.5; extra == "cli"
44
44
  Dynamic: license-file
45
45
 
46
46
  <div align="center">
@@ -101,6 +101,7 @@ Dynamic: license-file
101
101
  | **Bangumi** | | ✅ | 💬 条目讨论, 日志, 小组话题 |
102
102
  | **今日头条** | ✅ | ✅ | 📰 文章, 微头条 |
103
103
  | **Medium** | ✅ | ✅ | 📰 文章 |
104
+ | **煎蛋** | | ✅ | 📰 文章, 💬 话题 |
104
105
 
105
106
  ## 📦 安装
106
107
 
@@ -26,6 +26,7 @@ src/parsehub/parsers/parser/douban.py
26
26
  src/parsehub/parsers/parser/douyin.py
27
27
  src/parsehub/parsers/parser/facebook.py
28
28
  src/parsehub/parsers/parser/instagram.py
29
+ src/parsehub/parsers/parser/jandan.py
29
30
  src/parsehub/parsers/parser/kuaishou.py
30
31
  src/parsehub/parsers/parser/medium.py
31
32
  src/parsehub/parsers/parser/pipix.py
@@ -50,6 +51,7 @@ src/parsehub/provider_api/coolapk.py
50
51
  src/parsehub/provider_api/douban.py
51
52
  src/parsehub/provider_api/douyin.py
52
53
  src/parsehub/provider_api/instagram.py
54
+ src/parsehub/provider_api/jandan.py
53
55
  src/parsehub/provider_api/kuaishou.py
54
56
  src/parsehub/provider_api/medium.py
55
57
  src/parsehub/provider_api/pipix.py
@@ -76,11 +78,7 @@ src/parsehub/utils/downloader.py
76
78
  src/parsehub/utils/fallback.py
77
79
  src/parsehub/utils/helpers.py
78
80
  src/parsehub/utils/media_info.py
79
- test/test_bilibili_music_offline.py
80
- test/test_bilibili_offline.py
81
81
  test/test_cli.py
82
82
  test/test_cli_config.py
83
83
  test/test_core_offline.py
84
- test/test_downloader.py
85
- test/test_instagram_duration_offline.py
86
- test/test_zuiyou_duration_offline.py
84
+ test/test_downloader.py
@@ -0,0 +1,27 @@
1
+ aiofiles>=25.1.0
2
+ beautifulsoup4>=4.15.0
3
+ loguru>=0.7.3
4
+ pydub>=0.25.1
5
+ python-dotenv>=1.2.4
6
+ tenacity>=9.2.1
7
+ urlextract>=1.10.0
8
+ yt-dlp[default]>=2026.11.4.232659.dev0
9
+ lxml>=6.1.3
10
+ pydantic>=2.14.3
11
+ markdownify>=1.2.3
12
+ markdown>=3.11.3
13
+ json5>=0.17.3
14
+ requests>=2.34.2
15
+ httpx[socks]>=0.28.1
16
+ pillow>=13.0.0
17
+ python-slugify[unidecode]>=9.1.3
18
+ opencv-python-headless>=5.0.0.93
19
+ cryptography>=50.0.2
20
+ gmssl>=3.2.2
21
+ signerpy>=0.12.0
22
+ curl-cffi>=0.17.0
23
+ xhshow>=0.2.0
24
+
25
+ [cli]
26
+ argcomplete>=3.7.2
27
+ platformdirs>=4.14.5